execrpc package - github.com/bep/execrpc - Go Packages
- Constants
- Variables
- type Call
- type Client
- type ClientOptions
- type ClientRaw
- type ClientRawOptions
- type Dispatcher
- type Header
- type Identity
- type LastModifiedProvider
- type Message
- type ProtocolInfo
- type Result
- type Server
- type ServerOptions
- type ServerRaw
- type ServerRawOptions
- type SizeProvider
- type TagProvider
const ( MessageStatusOK = iota MessageStatusContinue MessageStatusInitServer MessageStatusErrDecodeFailed MessageStatusErrEncodeFailed MessageStatusErrInitServerFailed MessageStatusSystemReservedMax = 99 )
var ( ErrTimeoutWaitingForServer = errors.New("timed out waiting for server to start") ErrTimeoutWaitingForCall = errors.New("timed out waiting for call to complete") )
ErrShutdown will be returned from Execute and Close if the client is or is about to be shut down.
This section is empty.
type Call[Q, M, R any] struct { Request Q }
Call is the request/response exchange between the client and server. Note that the stream parameter S is optional, set it to any if not used.
Close closes the call and sends andy buffered messages and the receipt back to the client. If drop is true, the buffered messages are dropped. Note that drop is only relevant if the server is configured with DelayDelivery set to true.
func (c *Call[Q, M, R]) Enqueue(rr ...M)
Enqueue enqueues one or more messages to be sent back to the client.
func (c *Call[Q, M, R]) Receipt() <-chan R
type Client[C, Q, M, R any] struct { }
Client is a strongly typed RPC client.
func StartClient[C, Q, M, R any](opts ClientOptions[C, Q, M, R]) (*Client[C, Q, M, R], error)
StartClient starts a client for the given options.
Execute sends the request to the server and returns the result. You should check Err() both before and after reading from the messages and receipt channels.
ClientOptions are options for the client.
type ClientRaw struct {
Messages chan Message
}
ClientRaw is a raw RPC client. Raw means that the client doesn't do any type conversion, a byte slice is what you get.
StartClientRaw starts a untyped client client for the given options.
Close closes the server connection and waits for the server process to quit.
ClientRawOptions are options for the raw part of the client.
type Dispatcher interface {
SendMessage(...Message)
}
Dispatcher is the interface for dispatching messages to the client.
Header is the header of a message. ID and Size are set by the system. Status may be set by the system.
Read reads the header from the reader.
Write writes the header to the writer.
type Identity struct {
LastModified int64 `json:"lastModified"`
ETag string `json:"eTag"`
Size uint32 `json:"size"`
}
Identity holds the modified time (Unix seconds) and a 64-bit checksum.
GetESize returns the size.
GetETag returns the checksum.
SetETag sets the checksum.
LastModifiedProvider is the interface for a type that can provide a last modified time.
type Message struct {
Body []byte
}
Message is what gets sent to and from the server.
type ProtocolInfo struct {
Version uint16 `json:"version"`
}
ProtocolInfo is the protocol information passed to the server's Init function.
type Result[M, R any] struct { }
Result is the result of a request with zero or more messages and the receipt.
func (r Result[M, R]) Messages() <-chan M
Messages returns the messages from the server.
func (r Result[M, R]) Receipt() <-chan R
Receipt returns the receipt from the server.
Server is a stringly typed server for requests of type Q and responses of tye R.
func NewServer[C, Q, M, R any](opts ServerOptions[C, Q, M, R]) (*Server[C, Q, M, R], error)
NewServer creates a new Server. using the given options.
ServerOptions is the options for a server.
type ServerRaw struct {
}
ServerRaw is a RPC server handling raw messages with a header and []byte body. See Server for a generic, typed version.
NewServerRaw creates a new Server using the given options.
Start sets upt the server communication and starts the server loop.
type ServerRawOptions struct {
Call func(Message, Dispatcher) error
}
ServerRawOptions is the options for a raw portion of the server.
SizeProvider is the interface for a type that can provide a size.