Skip to content

drpcserver: server interceptors tests #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shaikzakiriitm
Copy link

Stacked on #7
This draft pr serves as an example of how the server interceptors will look like in drpc.
Here, we cook up a dummy chat server, and wire logging interceptor with this server. The logging interceptor intercepts all message receives and sends on the server. Sample output from server's logs are shown below:

GOROOT=/Users/zakirhussainshaik/go/pkg/mod/golang.org/[email protected] #gosetup
GOPATH=/Users/zakirhussainshaik/go #gosetup
/Users/zakirhussainshaik/go/pkg/mod/golang.org/[email protected]/bin/go build -o /Users/zakirhussainshaik/Library/Caches/JetBrains/GoLand2025.1/tmp/GoLand/___go_build_storj_io_drpc_drpcserver_cmd /Users/zakirhussainshaik/go/src/github.com/drpc-fork-zakir/drpcserver/cmd/server_main.go #gosetup
/Users/zakirhussainshaik/Library/Caches/JetBrains/GoLand2025.1/tmp/GoLand/___go_build_storj_io_drpc_drpcserver_cmd #gosetup


2025/06/09 16:27:48 DRPC server listening on :9000
2025/06/09 16:28:11 Server Interceptor: RPC Method /drpcserver.chatpb.ChatService/ChatStream called
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Received message: sender:"Client" text:"Hi"
2025/06/09 16:28:11 Received from Client: Hi
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Sending message: sender:"Server" text:"Echo: Hi"
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Received message: sender:"Client" text:"How are you?"
2025/06/09 16:28:11 Received from Client: How are you?
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Sending message: sender:"Server" text:"Echo: How are you?"
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Received message: sender:"Client" text:"Bye!"
2025/06/09 16:28:11 Received from Client: Bye!
2025/06/09 16:28:11 Server Interceptor (/drpcserver.chatpb.ChatService/ChatStream): Sending message: sender:"Server" text:"Echo: Bye!"
2025/06/09 16:28:11 stream closed or errored: context canceled
2025/06/09 16:28:11 Server Interceptor: RPC Method /drpcserver.chatpb.ChatService/ChatStream completed with error: context canceled (Duration: 921.458µs)

Process finished with the exit code 130 (interrupted by signal 2:SIGINT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant