diff --git a/opts.go b/opts.go index 2959dfc..c63a954 100644 --- a/opts.go +++ b/opts.go @@ -14,8 +14,9 @@ import ( // ServerOptions control the behaviour of a server created by NewServer. // A nil *ServerOptions provides sensible defaults. +// It is safe to share server options among multiple server instances. type ServerOptions struct { - // If not nil, send debug logs here. + // If not nil, send debug text logs here. Logger *log.Logger // If not nil, the methods of this value are called to log each request @@ -38,16 +39,16 @@ type ServerOptions struct { // along to the given assigner. DisableBuiltin bool - // Allows up to the specified number of goroutines to execute concurrently - // in request handlers. A value less than 1 uses runtime.NumCPU(). Note - // that this setting does not constrain order of issue. + // Allows up to the specified number of goroutines to execute in parallel in + // request handlers. A value less than 1 uses runtime.NumCPU(). Note that + // this setting does not constrain order of issue. Concurrency int // If set, this function is called with the method name and encoded request // parameters received from the client, before they are delivered to the // handler. Its return value replaces the context and argument values. This // allows the server to decode context metadata sent by the client. - // If unset, ctx and params are used as given. + // If unset, context and parameters are used as given. DecodeContext func(context.Context, string, json.RawMessage) (context.Context, json.RawMessage, error) // If set, this function is called with the context and client request @@ -62,7 +63,8 @@ type ServerOptions struct { Metrics *metrics.M // If nonzero this value as the server start time; otherwise, use the - // current time when Start is called. + // current time when Start is called. All servers created from the same + // options will share the same start time if one is set. StartTime time.Time } @@ -162,8 +164,8 @@ type ClientOptions struct { // The function receives the client and the response that was cancelled. // The hook can obtain the ID and error value from rsp. // - // Note that the hook does not receive the client context, which has already - // ended by the time the hook is called. + // Note that the hook does not receive the request context, which has + // already ended by the time the hook is called. OnCancel func(cli *Client, rsp *Response) }