Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientClosed is returned when a method is called on a closed Initiator. ErrClientClosed = errors.New("grpc initiator: closed") // ErrNilConn is returned by NewClient when given a nil grpc.ClientConn. ErrNilConn = errors.New("grpc initiator: nil connection") // ErrInvalidBufferSize is returned for negative buffer sizes. ErrInvalidBufferSize = errors.New("grpc initiator: buffer size cannot be negative") // ErrInvalidCallTimeout is returned for non-positive call timeouts. ErrInvalidCallTimeout = errors.New("grpc initiator: call timeout must be positive") )
var ( // ErrNilListener is returned by NewServer when given a nil net.Listener. ErrNilListener = errors.New("grpc server: listener cannot be nil") // ErrServerAlreadyRan is returned by Run if the server has already been started. ErrServerAlreadyRan = errors.New("grpc server: Run already called") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(conn *grpc.ClientConn, opts ...ClientOption) (*Client, error)
NewClient creates a new gRPC-backed Initiator. The caller retains ownership of conn and is responsible for closing it after the Client is closed.
func (*Client) Close ¶
Close signals all in-flight goroutines to stop delivering responses. It does not close the underlying grpc.ClientConn.
func (*Client) ReceiveTaskResponse ¶
ReceiveTaskResponse blocks until a task response is available, the context is cancelled, or the client is closed.
func (*Client) SendTaskRequest ¶
SendTaskRequest encodes the request and dispatches the gRPC call asynchronously. The resulting TaskResponse is placed on an internal channel for later retrieval via ReceiveTaskResponse.
type ClientOption ¶
type ClientOption func(*config) error
func WithBufferSize ¶
func WithBufferSize(n int) ClientOption
WithBufferSize sets the buffer of the internal responses channel. Defaults to 100. A larger buffer tolerates bursts of responses without blocking RPC goroutines at the send-to-channel step.
func WithCallTimeout ¶
func WithCallTimeout(d time.Duration) ClientOption
WithCallTimeout sets the per-RPC deadline used for Send calls. Defaults to 30 seconds. This is derived from context.Background, NOT the caller's ctx, because the reconcile transaction ctx handed to SendTaskRequest is too short-lived for the outbound RPC.
type Server ¶
type Server struct {
orbitalv1.UnimplementedTaskServiceServer
// contains filtered or unexported fields
}
Server implements the orbital TaskService gRPC server and the SyncResponder interface. It receives task requests over gRPC, processes them via the TaskRequestHandler provided to Run, and returns responses synchronously.
func NewServer ¶
func NewServer(lis net.Listener, opts ...ServerOption) (*Server, error)
NewServer creates a gRPC Server bound to the given listener.
func (*Server) Close ¶
Close gracefully stops the gRPC server. If ctx expires before graceful shutdown completes, it force-stops.
func (*Server) Run ¶
Run registers the TaskService, starts serving, and blocks until Close is called or ctx is cancelled. Run may only be called once.
func (*Server) SendTaskRequest ¶
func (s *Server) SendTaskRequest(ctx context.Context, pReq *orbitalv1.TaskRequest) (*orbitalv1.TaskResponse, error)
SendTaskRequest implements orbitalv1.TaskServiceServer.
type ServerOption ¶
type ServerOption func(*serverConfig) error
ServerOption configures a Server.
func WithServerOptions ¶
func WithServerOptions(opts ...grpc.ServerOption) ServerOption
WithServerOptions appends gRPC server options (interceptors, TLS credentials, etc.) used when the underlying grpc.Server is created.