Skip to content

atbigelow/grpc-svcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grpc-svcs: A gRPC integration for SVCS

Very in-development

Installation

pip install grpc-svcs

Usage

import grpc_svcs
import svcs

registry = svcs.Registry()
# Register services
registry.register_value(MyType, MyType())

# Attach a `SVCSInterceptor` when creating server.
server = grpc.server(intercepters=[grpc_svcs.SVCSInterceptor(registry)])

# Attach a `SVCSAsyncIntercept` when creating an async server.
server = grpc.aio.server(intercepters=[grpc_svcs.SVCSAsyncInterceptor(registry)])

# Retrieve container inside a servicer
class Greeter(helloworld_pb2_grpc.GreeterServicer):
    def SayHello(self, request, context):
        # call svcs_from
        container = grpc_svcs.svcs_from()
        # get items from svcs
        my_type = container.get(MyType)

        return helloworld_pb2.HelloReply(message="Hello, %s!" % request.name)

About

A GRPC integration for SVCS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages