hf,~dZdZGddeZGddeZGddeZGdd eZd S) a*Contains metaclasses used to create protocol service and service stub classes from ServiceDescriptor objects at runtime. The GeneratedServiceType and GeneratedServiceStubType metaclasses are used to inject all useful functionality into the classes output by the protocol compiler at compile-time. zpetar@google.com (Petar Petrov)ceZdZdZdZdZdS)GeneratedServiceTypeaMetaclass for service classes created at runtime from ServiceDescriptors. Implementations for all methods described in the Service class are added here by this class. We also create properties to allow getting/setting all fields in the protocol message. The protocol compiler currently uses this metaclass to create protocol service classes at runtime. Clients can also manually create their own classes at runtime, as in this example:: mydescriptor = ServiceDescriptor(.....) class MyProtoService(service.Service): __metaclass__ = GeneratedServiceType DESCRIPTOR = mydescriptor myservice_instance = MyProtoService() # ... DESCRIPTORctj|vrdS|tj}t|}||||_dS)aCreates a message service class. Args: name: Name of the class (ignored, but required by the metaclass protocol). bases: Base classes of the class being constructed. dictionary: The class dictionary of the class being constructed. dictionary[_DESCRIPTOR_KEY] must contain a ServiceDescriptor object describing this protocol service type. N)r_DESCRIPTOR_KEY_ServiceBuilder BuildServicer)clsnamebases dictionary descriptorservice_builders /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/service_reflection.py__init__zGeneratedServiceType.__init__@sQ+:== f0@AJ%j11O  %%%CNNNN)__name__ __module__ __qualname____doc__rrrrrr*s4$!/     rrc&eZdZdZdZfdZxZS)GeneratedServiceStubTypezMetaclass for service stubs created at runtime from ServiceDescriptors. This class has similar responsibilities as GeneratedServiceType, except that it creates the service stub classes. rctt||||tj|vrdS|tj}t |}||dS)a`Creates a message service stub class. Args: name: Name of the class (ignored, here). bases: Base classes of the class being constructed. dictionary: The class dictionary of the class being constructed. dictionary[_DESCRIPTOR_KEY] must contain a ServiceDescriptor object describing this protocol service type. N)superrrr_ServiceStubBuilderBuildServiceStub)r r r r r service_stub_builder __class__s rrz!GeneratedServiceStubType.__init__`ss "C((11$zJJJ /zAA f4DEJ.z::))#.....r)rrrrrr __classcell__)rs@rrrVsI !//////////rrc<eZdZdZdZdZdZdZdZdZ dZ d S) raDThis class constructs a protocol service class using a service descriptor. Given a service descriptor, this class constructs a class that represents the specified service descriptor. One service builder instance constructs exactly one service class. That means all instances of that class share the same builder. c||_dS)zInitializes an instance of the service class builder. Args: service_descriptor: ServiceDescriptor to use when constructing the service class. Nr selfservice_descriptors rrz_ServiceBuilder.__init__)DOOOrcfd}fd}fd}|_||_tfd|_d|j_||_||_jjD]+}t||j |,dS)z\Constructs the service class. Args: cls: The class that will be constructed. c6|||||SN) _CallMethod)r$method_descriptorrpc_controllerrequestdonebuilders r_WrapCallMethodz5_ServiceBuilder.BuildService.._WrapCallMethods'  '8.!($000rc.|Sr))_GetRequestClassr$r+r/s r_WrapGetRequestClassz:_ServiceBuilder.BuildService.._WrapGetRequestClasss  % %&7 8 88rc.|Sr))_GetResponseClassr3s r_WrapGetResponseClassz;_ServiceBuilder.BuildService.._WrapGetResponseClasss  & &'8 9 99rcjSr)r")r/srz._ServiceBuilder.BuildService..s W-?rzReturns the service descriptor.N) r CallMethod staticmethod GetDescriptorrGetRequestClassGetResponseClassr methodssetattrr _GenerateNonImplementedMethod)r/r r0r4r7methods` rrz_ServiceBuilder.BuildServices0000099999:::::GK$CN$%?%?%?%?@@C AC.C0C$,OO c6; E Ef M MNNNNOOrc|j|jkrtdt||j}||||S)aCalls the method described by a given method descriptor. Args: srvc: Instance of the service for which this method is called. method_descriptor: Descriptor that represent the method to call. rpc_controller: RPC controller to use for this method's execution. request: Request protocol message. callback: A callback to invoke after the method has completed. z>  H J JJ T,1 2 2F 6.'8 4 44rcX|j|jkrtd|jjS)aReturns the class of the request protocol message. Args: method_descriptor: Descriptor of the method for which to return the request protocol message class. Returns: A class that represents the input protocol message of the specified method. zAGetRequestClass() given method descriptor for wrong service type.)rDr rE input_type_concrete_classr$r+s rr2z _ServiceBuilder._GetRequestClasss8+t>>  M O OO  ' 77rcX|j|jkrtd|jjS)aReturns the class of the response protocol message. Args: method_descriptor: Descriptor of the method for which to return the response protocol message class. Returns: A class that represents the output protocol message of the specified method. zBGetResponseClass() given method descriptor for wrong service type.)rDr rE output_typerKrLs rr6z!_ServiceBuilder._GetResponseClasss8+t>>  N P PP  ( 88rcfdS)zGenerates and returns a method that can be set for a service methods. Args: method: Descriptor of the service method for which a method is to be generated. Returns: A method that can be added to the service class. c<j||Sr))_NonImplementedMethodr instr,r-rHrBr$s rr9z?_ServiceBuilder._GenerateNonImplementedMethod..s ""6;IIrrr$rBs``rrAz-_ServiceBuilder._GenerateNonImplementedMethods( K K K K KKrcL|d|z|ddS)a The body of all methods in the generated service class. Args: method_name: Name of the method being executed. rpc_controller: RPC controller used to execute this method. callback: A callback which will be invoked when the method finishes. zMethod %s not implemented.N) SetFailed)r$ method_namer,rHs rrQz%_ServiceBuilder._NonImplementedMethods/9KGHHH HTNNNNNrN) rrrrrrr*r2r6rArQrrrrrus)))OOO>555"888 999 K K K     rrc*eZdZdZdZdZdZdZdS)raConstructs a protocol service stub class using a service descriptor. Given a service descriptor, this class constructs a suitable stub class. A stub is just a type-safe wrapper around an RpcChannel which emulates a local implementation of the service. One service stub builder instance constructs exactly one class. It means all instances of that class share the same service stub builder. c||_dS)zInitializes an instance of the service stub class builder. Args: service_descriptor: ServiceDescriptor to use when constructing the stub class. Nr"r#s rrz_ServiceStubBuilder.__init__r&rcd}||_||_|jjD]+}t ||j||,dS)zYConstructs the stub class. Args: cls: The class that will be constructed. c||_dSr)) rpc_channel)stubr\s r_ServiceStubInitz>_ServiceStubBuilder.BuildServiceStub.._ServiceStubInit s$drN)r rr r?r@r _GenerateStubMethod)r$r r^rBs rrz$_ServiceStubBuilder.BuildServiceStubsf%%%DH#CL/)BB c6; 8 8 @ @AAAABBrcdfd S)Nc6||||Sr)) _StubMethodrRs rr9z9_ServiceStubBuilder._GenerateStubMethod..s! v~wIIrr)rrTs``rr_z'_ServiceStubBuilder._GenerateStubMethods. J J J J J JKrcR|j||||jj|S)aThe body of all service methods in the generated stub class. Args: stub: Stub instance. method_descriptor: Descriptor of the invoked method. rpc_controller: Rpc controller to execute the method. request: Request protocol message. callback: A callback to execute when the method finishes. Returns: Response message (in case of blocking call). )r\r:rNrK)r$r]r+r,r-rHs rrbz_ServiceStubBuilder._StubMethods4   & &>7%5x A AArN)rrrrrrr_rbrrrrrse))) B B BKKKAAAAArrN)r __author__typerrobjectrrrrrrgs>/ ) ) ) ) ) 4) ) ) X/////3///>yyyyyfyyyx6A6A6A6A6A&6A6A6A6A6Ar