def __init__(self, channel): self._client = purerpc.Client("Greeter", channel) self.SayHello = self._client.get_method_stub( "SayHello", purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) self.SayHelloGoodbye = self._client.get_method_stub( "SayHelloGoodbye", purerpc.RPCSignature( purerpc.Cardinality.UNARY_STREAM, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) self.SayHelloToMany = self._client.get_method_stub( "SayHelloToMany", purerpc.RPCSignature( purerpc.Cardinality.STREAM_STREAM, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) self.SayHelloToManyAtOnce = self._client.get_method_stub( "SayHelloToManyAtOnce", purerpc.RPCSignature( purerpc.Cardinality.STREAM_UNARY, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, ))
def service(self) -> purerpc.Service: service_obj = purerpc.Service("Greeter") service_obj.add_method( "SayHello", self.SayHello, purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) service_obj.add_method( "SayHelloGoodbye", self.SayHelloGoodbye, purerpc.RPCSignature( purerpc.Cardinality.UNARY_STREAM, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) service_obj.add_method( "SayHelloToMany", self.SayHelloToMany, purerpc.RPCSignature( purerpc.Cardinality.STREAM_STREAM, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) service_obj.add_method( "SayHelloToManyAtOnce", self.SayHelloToManyAtOnce, purerpc.RPCSignature( purerpc.Cardinality.STREAM_UNARY, generated.greeter_pb2.HelloRequest, generated.greeter_pb2.HelloReply, )) return service_obj
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: async with purerpc.secure_channel( self.endpoint, self.port, get_ssl_context(self.cert_path), ) as channel: client = purerpc.Client("lnrpc.Lightning", channel) subscribe_invoices = client.get_method_stub( "SubscribeInvoices", purerpc.RPCSignature( purerpc.Cardinality.UNARY_STREAM, ln.InvoiceSubscription, ln.Invoice, ), ) macaroon = load_macaroon(self.macaroon_path) async for inv in subscribe_invoices( ln.InvoiceSubscription(), metadata=[("macaroon", macaroon)], ): if not inv.settled: continue checking_id = stringify_checking_id(inv.r_hash) yield checking_id print("lost connection to lnd InvoiceSubscription, please restart lnbits.")
def __init__(self, channel): self._client = purerpc.Client("challenges.Challenge2", channel) self.create = self._client.get_method_stub( "create", purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, api_pb2.ChallengeRequest2, api_pb2.ChallengeResponse, ))
def service(self) -> purerpc.Service: service_obj = purerpc.Service("challenges.Challenge2") service_obj.add_method( "create", self.create, purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, api_pb2.ChallengeRequest2, api_pb2.ChallengeResponse, )) return service_obj
def __init__(self, channel): self._client = purerpc.Client("challenges.Challenge", channel) self.create = self._client.get_method_stub( "create", purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, api_pb2.ChallengeRequest, api_pb2.ChallengeResponse, )) self.bulk_create = self._client.get_method_stub( "bulk_create", purerpc.RPCSignature( purerpc.Cardinality.STREAM_STREAM, api_pb2.ChallengeRequest, api_pb2.ChallengeResponse, )) self.list = self._client.get_method_stub( "list", purerpc.RPCSignature( purerpc.Cardinality.UNARY_STREAM, google.protobuf.empty_pb2.Empty, api_pb2.ChallengeResponse, ))
def service(self) -> purerpc.Service: service_obj = purerpc.Service("challenges.Challenge") service_obj.add_method( "create", self.create, purerpc.RPCSignature( purerpc.Cardinality.UNARY_UNARY, api_pb2.ChallengeRequest, api_pb2.ChallengeResponse, )) service_obj.add_method( "bulk_create", self.bulk_create, purerpc.RPCSignature( purerpc.Cardinality.STREAM_STREAM, api_pb2.ChallengeRequest, api_pb2.ChallengeResponse, )) service_obj.add_method( "list", self.list, purerpc.RPCSignature( purerpc.Cardinality.UNARY_STREAM, google.protobuf.empty_pb2.Empty, api_pb2.ChallengeResponse, )) return service_obj