Package 

Class Broker


  • 
    public final class Broker
    
                        

    Broker facilitates bi-directional communication between the plugin client and server.

    • Method Summary

      Modifier and Type Method Description
      final Integer getNextId() Returns the next service ID.
      final Server acceptAndServe(Integer serviceId, BindableService services) Starts a gRPC server as a callback endpoint.
      final ManagedChannel dial(Integer serviceId) Dials a gRPC endpoint.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getNextId

         final Integer getNextId()

        Returns the next service ID.

        When a client-side plugin expects a callback from a server-side plugin implementation, it must first acquire a service ID. The service ID is a correlation ID for network coordinates that Broker will send out-of-band to the server once acceptAndServe has been called.

        The client must send the service ID as part of its initial gRPC message to the server.

      • acceptAndServe

         final Server acceptAndServe(Integer serviceId, BindableService services)

        Starts a gRPC server as a callback endpoint.

        Clients should call acceptAndServe after acquiring a service ID but before sending the service ID to the server.

        The client is responsible for cleaning up the returned Server after the client-server call sequence has completed.

        The flow for a plugin implementor typically looks like this:

        • The client acquires a service ID via getNextId.

        • The client serves one or more gRPC services via acceptAndServe.

        • The client sends a message that includes its service ID ("please dial me back at this number").

        • The server-side plugin implementation receives the message containing the service ID. The Go plugin framework has a method identical to dial below that accepts a service ID and facilitates communication back to the client. The server-side plugin should handle this callback synchronously.

        • The client cleans up its server.

        Parameters:
        serviceId - The acquired service ID.
        services - The gRPC services that the Broker should serve.
      • dial

         final ManagedChannel dial(Integer serviceId)

        Dials a gRPC endpoint.

        Method dial is the complement of acceptAndServe. It should be used when a server has passed the client a service ID that should be used to call back the server. This should be rare, since this only arises if the client is calling back the server after the server called back the client.

        Parameters:
        serviceId - A service ID provided by the plugin server.