Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Context ¶
type Context interface {
context.Context
// SetContext can be used to wrap the context.Context with additonal deadlines, ...
SetContext(ctx context.Context)
// Session returns the current active session.
Session() Session
// SetRaw sets the raw header byte slice defined by the key.
// This data is send to the service.
SetHeader(key string, data []byte)
// Data returns the value defined by the key. Returns nil if not present.
Data(key string) interface{}
// SetData sets the value defined by the key.
SetData(key string, v interface{})
}
A Context defines the client context which extends the context.Context interface.
type Error ¶
type Error interface {
// Embeds the standard go error interface.
error
// Code returns an integer that can give a hint about the
// type of error that occurred.
Code() int
}
The Error type extends the standard go error by a simple integer code. It is returned in the Call- functions of this package and allows callers that use them to check for common errors via the code.
type Hook ¶
type Hook interface {
// Close is called if the client closes.
Close() error
// OnSession is called if a new client session is connected to the service.
// RPC and stream routines are handled after this hook.
// Do not use the stream after returning from this hook.
// Return an error to close the session and abort the initialization process.
OnSession(s Session, stream transport.Stream) error
// OnSessionClosed is called as soon as the session closes.
OnSessionClosed(s Session)
// OnCall is called before a call request.
// Return an error to abort the call.
OnCall(ctx Context, id string, callKey uint32) error
// OnCallDone is called after a call request.
// The context is the same as from the OnCall hook.
// If err == nil, then the call completed successfully.
OnCallDone(ctx Context, id string, callKey uint32, err error)
// OnCallCanceled is called, if a call is canceled.
// The context is the same as from the OnCall hook.
OnCallCanceled(ctx Context, id string, callKey uint32)
// OnStream is called during a new stream setup.
// Return an error to abort the stream setup.
OnStream(ctx Context, id string, stream transport.Stream) error
}
Hook allows third-party code to hook into orbit's logic, to implement for example logging or authentication functionality.
type Options ¶
type Options struct {
// Host specifies the destination host address. This value must be set.
Host string
// Transport specifies the communication backend. This value must be set.
Transport transport.Transport
// Closer defines the closer instance. A default closer will be created if unspecified.
Closer closer.Closer
// Codec defines the transport encoding. A default codec will be used if unspecified.
Codec codec.Codec
// Hooks specifies the hooks executed during certain actions. The order of the hooks is stricly followed.
Hooks Hooks
// Log specifies the default logger backend. A default logger will be used if unspecified.
Log *zerolog.Logger
// CallTimeout specifies the default timeout for each call.
// Set to -1 for no timeout.
CallTimeout time.Duration
// ConnectTimeout specifies the timeout duration after a service connect attempt.
ConnectTimeout time.Duration
// ConnectThrottleDuration specifies the wait duration between subsequent connection attempts.
ConnectThrottleDuration time.Duration
// HandshakeTimeout specifies the connection initialization timeout.
HandshakeTimeout time.Duration
// StreamInitTimeout specifies the default timeout for a stream setup.
StreamInitTimeout time.Duration
// PrintPanicStackTraces prints stack traces of catched panics.
PrintPanicStackTraces bool
}
Click to show internal directories.
Click to hide internal directories.