Documentation
¶
Overview ¶
Package client provides a RemoteTransport that connects to an event server.
Index ¶
- Variables
- type ConnState
- type Option
- func WithCallTimeout(d time.Duration) Option
- func WithCircuitBreaker(threshold int, timeout time.Duration) Option
- func WithDialOptions(opts ...grpc.DialOption) Option
- func WithInsecure() Option
- func WithKeepalive(time, timeout time.Duration) Option
- func WithRetry(maxRetries int, initialBackoff, maxBackoff time.Duration) Option
- func WithStateCallback(fn func(ConnState)) Option
- func WithStreamErrorCallback(fn func(error)) Option
- func WithSubscribeBufferSize(size int) Option
- func WithSubscribeMaxErrors(n int) Option
- func WithSubscribeReconnect(enabled bool, waitTime time.Duration) Option
- func WithTLS(config *tls.Config) Option
- type PermissionDeniedError
- type RemoteError
- type RemoteTransport
- func (t *RemoteTransport) Close(ctx context.Context) error
- func (t *RemoteTransport) Connect(ctx context.Context) error
- func (t *RemoteTransport) Publish(ctx context.Context, name string, msg transport.Message) error
- func (t *RemoteTransport) Ready() bool
- func (t *RemoteTransport) RegisterEvent(ctx context.Context, name string) error
- func (t *RemoteTransport) State() ConnState
- func (t *RemoteTransport) Subscribe(ctx context.Context, name string, opts ...transport.SubscribeOption) (transport.Subscription, error)
- func (t *RemoteTransport) UnregisterEvent(ctx context.Context, name string) error
Constants ¶
This section is empty.
Variables ¶
var ErrPermissionDenied = errors.New("event: permission denied")
ErrPermissionDenied is returned when the server denies access to an event.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
Option configures the RemoteTransport.
func WithCallTimeout ¶
WithCallTimeout sets a per-attempt timeout for each gRPC call within a retry loop.
func WithCircuitBreaker ¶
WithCircuitBreaker enables circuit breaker for resilience.
func WithDialOptions ¶
func WithDialOptions(opts ...grpc.DialOption) Option
WithDialOptions appends additional gRPC dial options.
func WithInsecure ¶
func WithInsecure() Option
WithInsecure explicitly enables insecure connections (no TLS). This should only be used for development/testing.
func WithKeepalive ¶
WithKeepalive configures gRPC keepalive parameters.
func WithStateCallback ¶
WithStateCallback sets a callback for connection state changes.
func WithStreamErrorCallback ¶
WithStreamErrorCallback sets a callback for subscribe stream errors.
func WithSubscribeBufferSize ¶
WithSubscribeBufferSize sets the buffer size for subscribe message channels.
func WithSubscribeMaxErrors ¶
WithSubscribeMaxErrors sets the maximum number of consecutive subscribe errors before giving up. Default is 10.
func WithSubscribeReconnect ¶
WithSubscribeReconnect enables automatic reconnection for subscribe streams.
type PermissionDeniedError ¶
type PermissionDeniedError struct {
Message string
}
PermissionDeniedError provides details about a permission denial.
func (*PermissionDeniedError) Error ¶
func (e *PermissionDeniedError) Error() string
func (*PermissionDeniedError) Is ¶
func (e *PermissionDeniedError) Is(target error) bool
type RemoteError ¶
RemoteError wraps an error from the remote event server.
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type RemoteTransport ¶
type RemoteTransport struct {
// contains filtered or unexported fields
}
RemoteTransport implements transport.Transport by connecting to an event server. It is safe for concurrent use by multiple goroutines.
func New ¶
func New(addr string, opts ...Option) (*RemoteTransport, error)
New creates a new RemoteTransport connecting to the given address.
func (*RemoteTransport) Close ¶
func (t *RemoteTransport) Close(ctx context.Context) error
Close shuts down the transport and releases resources.
func (*RemoteTransport) Connect ¶
func (t *RemoteTransport) Connect(ctx context.Context) error
Connect establishes the connection to the event server.
func (*RemoteTransport) Ready ¶
func (t *RemoteTransport) Ready() bool
Ready returns true if the transport is connected and ready.
func (*RemoteTransport) RegisterEvent ¶
func (t *RemoteTransport) RegisterEvent(ctx context.Context, name string) error
RegisterEvent creates transport resources for a named event.
func (*RemoteTransport) State ¶
func (t *RemoteTransport) State() ConnState
State returns the current connection state.
func (*RemoteTransport) Subscribe ¶
func (t *RemoteTransport) Subscribe(ctx context.Context, name string, opts ...transport.SubscribeOption) (transport.Subscription, error)
Subscribe creates a subscription to receive messages for an event.
func (*RemoteTransport) UnregisterEvent ¶
func (t *RemoteTransport) UnregisterEvent(ctx context.Context, name string) error
UnregisterEvent removes transport resources for a named event.