This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSON | {'id':42} | 9 bytes | |
---|---|---|---|
XML | <id>42</id> | 11 bytes | |
protobuf | 0x08 0x2a | 2 bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grpc | |
from protos.user_store_pb2 import User, UserResponse, UserEmailRequest, | |
from protos.user_store_pb2_grpc import UserStoreServicer | |
class UserStoreServicer(UserStoreServicer): | |
def GetUserDataByEmail(self, request: UserEmailRequest, context): | |
user = … # your code for fetching the user data | |
return UserResponse( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grpc | |
from protos.user_store_pb2 import User, UserResponse, UserEmailRequest, | |
from protos.user_store_pb2_grpc import UserStoreStub | |
def run(): | |
with grpc.insecure_channel('localhost:50051') as channel: | |
stub = _pb2_grpc.UserStoreStub(channel) | |
response = stub.GetUserDataByEmail( | |
UserEmailRequest(email="[email protected]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3 | |
service UserStore { | |
rpc GetUserDataByEmail(UserEmailRequest) returns (UserResponse); | |
} | |
message User { | |
string email = 1; | |
string firstname = 2; | |
string lastname = 3; |