Documentation ¶
Index ¶
- Constants
- Variables
- func BackoffUntil(f func(), backoff BackoffManager, sliding bool, stopCh <-chan struct{})
- func ExponentialBackoff(backoff Backoff, condition ConditionFunc) error
- func FilterOut(err error, fns ...Matcher) error
- func FinishRequest(timeout time.Duration, fn resultFunc) (result interface{}, err error)
- func Forever(f func(), period time.Duration)
- func GetCaller() string
- func HandleCrash(additionalHandlers ...func(interface{}))
- func HandleError(err error)
- func Jitter(duration time.Duration, maxFactor float64) time.Duration
- func JitterUntil(f func(), period time.Duration, jitterFactor float64, sliding bool, ...)
- func JitterUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration, ...)
- func Must(err error)
- func NonSlidingUntil(f func(), period time.Duration, stopCh <-chan struct{})
- func NonSlidingUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration)
- func Poll(interval, timeout time.Duration, condition ConditionFunc) error
- func PollImmediate(interval, timeout time.Duration, condition ConditionFunc) error
- func PollImmediateInfinite(interval time.Duration, condition ConditionFunc) error
- func PollImmediateUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error
- func PollInfinite(interval time.Duration, condition ConditionFunc) error
- func PollUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error
- func RecoverFromPanic(err *error)
- func Reduce(err error) error
- func RequestShutdown() bool
- func RunServer(server *http.Server, ln net.Listener, shutDownTimeout time.Duration, ...) <-chan struct{}
- func SetupSignalHandler() <-chan struct{}
- func Until(f func(), period time.Duration, stopCh <-chan struct{})
- func UntilWithContext(ctx context.Context, f func(context.Context), period time.Duration)
- func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error
- type Aggregate
- type Backoff
- type BackoffManager
- type Clock
- type ConditionFunc
- type DialFunc
- type Dialer
- type FSErrorHandler
- type FSEventHandler
- type FSWatcher
- type FakeClock
- func (f *FakeClock) After(d time.Duration) <-chan time.Time
- func (f *FakeClock) HasWaiters() bool
- func (f *FakeClock) NewTicker(d time.Duration) Ticker
- func (f *FakeClock) NewTimer(d time.Duration) Timer
- func (f *FakeClock) SetTime(t time.Time)
- func (f *FakeClock) Sleep(d time.Duration)
- func (f *FakeClock) Step(d time.Duration)
- type FakePassiveClock
- type Group
- func (g *Group) Start(f func())
- func (g *Group) StartWithChannel(stopCh <-chan struct{}, f func(stopCh <-chan struct{}))
- func (g *Group) StartWithChannelAndErr(stopCh <-chan struct{}, f func(stopCh <-chan struct{}) error)
- func (g *Group) StartWithContext(ctx context.Context, f func(context.Context))
- func (g *Group) Wait()
- type Info
- type ListenerAndHandler
- type Matcher
- type MessageCountMap
- type OrangeServer
- func (s *OrangeServer) AddPostStartHook(name string, hook PostStartHookFunc) error
- func (s *OrangeServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc)
- func (s *OrangeServer) AddPreShutdownHook(name string, hook PreShutdownHookFunc) error
- func (s *OrangeServer) AddPreShutdownHookOrDie(name string, hook PreShutdownHookFunc)
- func (s *OrangeServer) Run(opt ...ServerOption) error
- func (s *OrangeServer) Serve(handler http.Handler, shutdownTimeout time.Duration, stopCh <-chan struct{}) <-chan struct{}
- type PassiveClock
- type PostStartHookContext
- type PostStartHookFunc
- type PostStartHookProvider
- type PreShutdownHookFunc
- type RateLimiter
- type RealClock
- type Runner
- type SafeWaitGroup
- type ServerOption
- type Ticker
- type Timer
- type WaitFunc
Constants ¶
const ( HTTP proto = iota TCP UDP HTTP2 )
Variables ¶
var ErrPreconditionViolated = errors.New("precondition is violated")
ErrPreconditionViolated is returned when the precondition is violated
var ErrWaitTimeout = errors.New("timed out waiting for the condition")
ErrWaitTimeout is returned when the condition exited without success.
var ErrorHandlers = []func(error){ logError, (&rudimentaryErrorBackoff{ lastErrorTime: time.Now(), minPeriod: time.Millisecond, }).OnError, }
ErrorHandlers is a list of functions which will be invoked when an unreturnable error occurs. TODO(lavalamp): for testability, this and the below HandleError function should be packaged up into a testable and reusable object.
var ForeverTestTimeout = time.Second * 30
For any test of the style:
... <- time.After(timeout): t.Errorf("Timed out")
The value for timeout should effectively be "forever." Obviously we don't want our tests to truly lock up forever, but 30s is long enough that it is effectively forever for the things that can slow down a run on a heavily contended machine (GC, seeks, etc), but not so long as to make a developer ctrl-c a test run if they do happen to break that test.
var NeverStop <-chan struct{} = make(chan struct{})
NeverStop may be passed to Until to make it never stop.
var PanicHandlers = []func(interface{}){logPanic}
PanicHandlers is a list of functions which will be invoked when a panic happens.
var ( // ReallyCrash controls the behavior of HandleCrash and now defaults // true. It's still exposed so components can optionally set to false // to restore prior behavior. ReallyCrash = true )
Functions ¶
func BackoffUntil ¶
func BackoffUntil(f func(), backoff BackoffManager, sliding bool, stopCh <-chan struct{})
BackoffUntil loops until stop channel is closed, run f every duration given by BackoffManager.
If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f.
func ExponentialBackoff ¶
func ExponentialBackoff(backoff Backoff, condition ConditionFunc) error
ExponentialBackoff repeats a condition check with exponential backoff.
It checks the condition up to Steps times, increasing the wait by multiplying the previous duration by Factor.
If Jitter is greater than zero, a random amount of each duration is added (between duration and duration*(1+jitter)).
If the condition never returns true, ErrWaitTimeout is returned. All other errors terminate immediately.
func FilterOut ¶
FilterOut removes all errors that match any of the matchers from the input error. If the input is a singular error, only that error is tested. If the input implements the Aggregate interface, the list of errors will be processed recursively.
This can be used, for example, to remove known-OK errors (such as io.EOF or os.PathNotFound) from a list of errors.
func FinishRequest ¶
finishRequest makes a given resultFunc asynchronous and handles errors returned by the response. An api.Status object with status != success is considered an "error", which interrupts the normal response flow.
func GetCaller ¶
func GetCaller() string
GetCaller returns the caller of the function that calls it.
func HandleCrash ¶
func HandleCrash(additionalHandlers ...func(interface{}))
HandleCrash simply catches a crash and logs an error. Meant to be called via defer. Additional context-specific handlers can be provided, and will be called in case of panic. HandleCrash actually crashes, after calling the handlers and logging the panic message.
E.g., you can provide one or more additional handlers for something like shutting down go routines gracefully.
func HandleError ¶
func HandleError(err error)
HandlerError is a method to invoke when a non-user facing piece of code cannot return an error and needs to indicate it has been ignored. Invoking this method is preferable to logging the error - the default behavior is to log but the errors may be sent to a remote server for analysis.
func Jitter ¶
Jitter returns a time.Duration between duration and duration + maxFactor * duration.
This allows clients to avoid converging on periodic behavior. If maxFactor is 0.0, a suggested default value will be chosen.
func JitterUntil ¶
func JitterUntil(f func(), period time.Duration, jitterFactor float64, sliding bool, stopCh <-chan struct{})
JitterUntil loops until stop channel is closed, running f every period.
If jitterFactor is positive, the period is jittered before every run of f. If jitterFactor is not positive, the period is unchanged and not jittered.
If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f.
Close stopCh to stop. f may not be invoked if stop channel is already closed. Pass NeverStop to if you don't want it stop.
func JitterUntilWithContext ¶
func JitterUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration, jitterFactor float64, sliding bool)
JitterUntilWithContext loops until context is done, running f every period.
func Must ¶
func Must(err error)
Must panics on non-nil errors. Useful to handling programmer level errors.
func NonSlidingUntil ¶
NonSlidingUntil loops until stop channel is closed, running f every period.
NonSlidingUntil is syntactic sugar on top of JitterUntil with zero jitter factor, with sliding = false (meaning the timer for period starts at the same time as the function starts).
func NonSlidingUntilWithContext ¶
NonSlidingUntilWithContext loops until context is done, running f every period.
NonSlidingUntilWithContext is syntactic sugar on top of JitterUntilWithContext with zero jitter factor, with sliding = false (meaning the timer for period starts at the same time as the function starts).
func Poll ¶
func Poll(interval, timeout time.Duration, condition ConditionFunc) error
Poll tries a condition func until it returns true, an error, or the timeout is reached.
Poll always waits the interval before the run of 'condition'. 'condition' will always be invoked at least once.
Some intervals may be missed if the condition takes too long or the time window is too short.
If you want to Poll something forever, see PollInfinite.
func PollImmediate ¶
func PollImmediate(interval, timeout time.Duration, condition ConditionFunc) error
PollImmediate tries a condition func until it returns true, an error, or the timeout is reached.
PollImmediate always checks 'condition' before waiting for the interval. 'condition' will always be invoked at least once.
Some intervals may be missed if the condition takes too long or the time window is too short.
If you want to immediately Poll something forever, see PollImmediateInfinite.
func PollImmediateInfinite ¶
func PollImmediateInfinite(interval time.Duration, condition ConditionFunc) error
PollImmediateInfinite tries a condition func until it returns true or an error
PollImmediateInfinite runs the 'condition' before waiting for the interval.
Some intervals may be missed if the condition takes too long or the time window is too short.
func PollImmediateUntil ¶
func PollImmediateUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error
PollImmediateUntil tries a condition func until it returns true, an error or stopCh is closed.
PollImmediateUntil runs the 'condition' before waiting for the interval. 'condition' will always be invoked at least once.
func PollInfinite ¶
func PollInfinite(interval time.Duration, condition ConditionFunc) error
PollInfinite tries a condition func until it returns true or an error
PollInfinite always waits the interval before the run of 'condition'.
Some intervals may be missed if the condition takes too long or the time window is too short.
func PollUntil ¶
func PollUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error
PollUntil tries a condition func until it returns true, an error or stopCh is closed.
PollUntil always waits interval before the first run of 'condition'. 'condition' will always be invoked at least once.
func RecoverFromPanic ¶
func RecoverFromPanic(err *error)
RecoverFromPanic replaces the specified error with an error containing the original error, and the call tree when a panic occurs. This enables error handlers to handle errors and panics the same way.
func Reduce ¶
Reduce will return err or, if err is an Aggregate and only has one item, the first item in the aggregate.
func RequestShutdown ¶
func RequestShutdown() bool
RequestShutdown emulates a received event that is considered as shutdown signal (SIGTERM/SIGINT) This returns whether a handler was notified
func RunServer ¶
func RunServer( server *http.Server, ln net.Listener, shutDownTimeout time.Duration, stopCh <-chan struct{}, ) <-chan struct{}
RunServer spawns a go-routine continuously serving until the stopCh is closed.
func SetupSignalHandler ¶
func SetupSignalHandler() <-chan struct{}
SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.
func Until ¶
Until loops until stop channel is closed, running f every period.
Until is syntactic sugar on top of JitterUntil with zero jitter factor and with sliding = true (which means the timer for period starts after the f completes).
func UntilWithContext ¶
UntilWithContext loops until context is done, running f every period.
UntilWithContext is syntactic sugar on top of JitterUntilWithContext with zero jitter factor and with sliding = true (which means the timer for period starts after the f completes).
func WaitFor ¶
func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error
WaitFor continually checks 'fn' as driven by 'wait'.
WaitFor gets a channel from 'wait()”, and then invokes 'fn' once for every value placed on the channel and once more when the channel is closed. If the channel is closed and 'fn' returns false without error, WaitFor returns ErrWaitTimeout.
If 'fn' returns an error the loop ends and that error is returned. If 'fn' returns true the loop ends and nil is returned.
ErrWaitTimeout will be returned if the 'done' channel is closed without fn ever returning true.
When the done channel is closed, because the golang `select` statement is "uniform pseudo-random", the `fn` might still run one or multiple time, though eventually `WaitFor` will return.
Types ¶
type Aggregate ¶
Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.
func AggregateGoroutines ¶
AggregateGoroutines runs the provided functions in parallel, stuffing all non-nil errors into the returned Aggregate. Returns nil if all the functions complete successfully.
func CreateAggregateFromMessageCountMap ¶
func CreateAggregateFromMessageCountMap(m MessageCountMap) Aggregate
CreateAggregateFromMessageCountMap converts MessageCountMap Aggregate
func Flatten ¶
Flatten takes an Aggregate, which may hold other Aggregates in arbitrary nesting, and flattens them all into a single Aggregate, recursively.
func NewAggregate ¶
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil. It will check if any of the element of input error list is nil, to avoid nil pointer panic when call Error().
type Backoff ¶
type Backoff struct { // The initial duration. Duration time.Duration // Duration is multiplied by factor each iteration. Must be greater // than or equal to zero. Factor float64 // The amount of jitter applied each iteration. Jitter is applied after // cap. Jitter float64 // The number of steps before duration stops changing. If zero, initial // duration is always used. Used for exponential backoff in combination // with Factor. Steps int // The returned duration will never be greater than cap *before* jitter // is applied. The actual maximum cap is `cap * (1.0 + jitter)`. Cap time.Duration }
Backoff holds parameters applied to a Backoff function.
type BackoffManager ¶
type BackoffManager interface {
Backoff() Timer
}
BackoffManager manages backoff with a particular scheme based on its underlying implementation. It provides an interface to return a timer for backoff, and caller shall backoff until Timer.C returns. If the second Backoff() is called before the timer from the first Backoff() call finishes, the first timer will NOT be drained. The BackoffManager is supposed to be called in a single-threaded environment.
func NewExponentialBackoffManager ¶
func NewExponentialBackoffManager(initBackoff, maxBackoff, resetDuration time.Duration, backoffFactor, jitter float64, c Clock) BackoffManager
NewExponentialBackoffManager returns a manager for managing exponential backoff. Each backoff is jittered and backoff will not exceed the given max. If the backoff is not called within resetDuration, the backoff is reset. This backoff manager is used to reduce load during upstream unhealthiness.
func NewJitteredBackoffManager ¶
func NewJitteredBackoffManager(duration time.Duration, jitter float64, c Clock) BackoffManager
NewJitteredBackoffManager returns a BackoffManager that backoffs with given duration plus given jitter. If the jitter is negative, backoff will not be jittered.
type Clock ¶
type Clock interface { PassiveClock After(time.Duration) <-chan time.Time NewTimer(time.Duration) Timer Sleep(time.Duration) NewTicker(time.Duration) Ticker }
Clock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.
type ConditionFunc ¶
ConditionFunc returns true if the condition is satisfied, or an error if the loop should be aborted.
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer opens connections through Dial and tracks them.
func NewDialer ¶
NewDialer creates a new Dialer instance.
If dial is not nil, it will be used to create new underlying connections. Otherwise net.DialContext is used.
func (*Dialer) CloseAll ¶
func (d *Dialer) CloseAll()
CloseAll forcibly closes all tracked connections.
type FSErrorHandler ¶
type FSErrorHandler func(err error)
FSErrorHandler is called when a fsnotify error occurs.
type FSEventHandler ¶
FSEventHandler is called when a fsnotify event occurs.
type FSWatcher ¶
type FSWatcher interface { // Initializes the watcher with the given watch handlers. // Called before all other methods. Init(FSEventHandler, FSErrorHandler) error // Starts listening for events and errors. // When an event or error occurs, the corresponding handler is called. Run() // Add a filesystem path to watch AddWatch(path string) error }
FSWatcher is a callback-based filesystem watcher abstraction for fsnotify.
func NewFsnotifyWatcher ¶
func NewFsnotifyWatcher() FSWatcher
NewFsnotifyWatcher returns an implementation of FSWatcher that continuously listens for fsnotify events and calls the event handler as soon as an event is received.
type FakeClock ¶
type FakeClock struct { FakePassiveClock // contains filtered or unexported fields }
FakeClock implements Clock, but returns an arbitrary time.
func (*FakeClock) HasWaiters ¶
HasWaiters returns true if After has been called on f but not yet satisfied (so you can write race-free tests).
type FakePassiveClock ¶
type FakePassiveClock struct {
// contains filtered or unexported fields
}
FakePassiveClock implements PassiveClock, but returns an arbitrary time.
func NewFakePassiveClock ¶
func NewFakePassiveClock(t time.Time) *FakePassiveClock
NewFakePassiveClock returns a new FakePassiveClock.
func (*FakePassiveClock) SetTime ¶
func (f *FakePassiveClock) SetTime(t time.Time)
SetTime sets the time on the FakePassiveClock.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group allows to start a group of goroutines and wait for their completion.
func (*Group) Start ¶
func (g *Group) Start(f func())
Start starts f in a new goroutine in the group.
func (*Group) StartWithChannel ¶
func (g *Group) StartWithChannel(stopCh <-chan struct{}, f func(stopCh <-chan struct{}))
StartWithChannel starts f in a new goroutine in the group. stopCh is passed to f as an argument. f should stop when stopCh is available.
func (*Group) StartWithChannelAndErr ¶
func (g *Group) StartWithChannelAndErr(stopCh <-chan struct{}, f func(stopCh <-chan struct{}) error)
StartWithChannel starts f in a new goroutine in the group. stopCh is passed to f as an argument. f should stop when stopCh is available.
func (*Group) StartWithContext ¶
StartWithContext starts f in a new goroutine in the group. ctx is passed to f as an argument. f should stop when ctx.Done() is available.
type Info ¶
type Info struct { Major string `json:"major"` Minor string `json:"minor"` Patch string `json:"Path"` }
Info contains versioning information.
var Version Info
type ListenerAndHandler ¶
type MessageCountMap ¶
MessageCountMap contains occurrence for each error message.
type OrangeServer ¶
type OrangeServer struct { // MinTLSVersion optionally overrides the minimum TLS version supported. MinTLSVersion uint16 // CipherSuites optionally overrides the list of allowed cipher suites for the server. CipherSuites []uint16 // HTTP2MaxStreamsPerConnection is the limit that the api server imposes on each client. HTTP2MaxStreamsPerConnection int // Handler holds the handlers being used by this API server Listener net.Listener Handler *restful.Container // ShutdownDelayDuration allows to block shutdown for some time ShutdownDelayDuration time.Duration // HandlerChainWaitGroup allows you to wait for all chain handlers finish after the server shutdown. HandlerChainWaitGroup *SafeWaitGroup // ShutdownTimeout is the timeout used for server shutdown. This specifies the timeout before server // gracefully shutdown returns. ShutdownTimeout time.Duration // contains filtered or unexported fields }
func MakeServer ¶
func MakeServer(name, port string, handle *restful.Container) *OrangeServer
func (*OrangeServer) AddPostStartHook ¶
func (s *OrangeServer) AddPostStartHook(name string, hook PostStartHookFunc) error
AddPostStartHook allows you to add a PostStartHook.
func (*OrangeServer) AddPostStartHookOrDie ¶
func (s *OrangeServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc)
AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure
func (*OrangeServer) AddPreShutdownHook ¶
func (s *OrangeServer) AddPreShutdownHook(name string, hook PreShutdownHookFunc) error
AddPreShutdownHook allows you to add a PreShutdownHook.
func (*OrangeServer) AddPreShutdownHookOrDie ¶
func (s *OrangeServer) AddPreShutdownHookOrDie(name string, hook PreShutdownHookFunc)
AddPreShutdownHookOrDie allows you to add a PostStartHook, but dies on failure
func (*OrangeServer) Run ¶
func (s *OrangeServer) Run(opt ...ServerOption) error
func (*OrangeServer) Serve ¶
func (s *OrangeServer) Serve(handler http.Handler, shutdownTimeout time.Duration, stopCh <-chan struct{}) <-chan struct{}
Serve runs the secure http server. It fails only if certificates cannot be loaded or the initial listen call fails. The actual server loop (stoppable by closing stopCh) runs in a go routine, i.e. Serve does not block. It returns a stoppedCh that is closed when all non-hijacked active requests have been processed.
type PassiveClock ¶
PassiveClock allows for injecting fake or real clocks into code that needs to read the current time but does not support scheduling activity in the future.
type PostStartHookContext ¶
type PostStartHookContext struct {
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
StopCh <-chan struct{}
}
PostStartHookContext provides information about this API server to a PostStartHookFunc
type PostStartHookFunc ¶
type PostStartHookFunc func(context PostStartHookContext) error
PostStartHookFunc is a function that is called after the server has started.
type PostStartHookProvider ¶
type PostStartHookProvider interface {
PostStartHook() (string, PostStartHookFunc, error)
}
PostStartHookProvider is an interface in addition to provide a post start hook for the api server
type PreShutdownHookFunc ¶
type PreShutdownHookFunc func() error
PreShutdownHookFunc is a function that can be added to the shutdown logic.
type RateLimiter ¶
type RateLimiter interface { // TryAccept returns true if a token is taken immediately. Otherwise, // it returns false. TryAccept() bool // Accept returns once a token becomes available. Accept() // Stop stops the rate limiter, subsequent calls to CanAccept will return false Stop() // QPS returns QPS of this rate limiter QPS() float32 // Wait returns nil if a token is taken before the Context is done. Wait(ctx context.Context) error }
func NewFakeAlwaysRateLimiter ¶
func NewFakeAlwaysRateLimiter() RateLimiter
func NewTokenBucketRateLimiter ¶
func NewTokenBucketRateLimiter(qps float32, burst int) RateLimiter
NewTokenBucketRateLimiter creates a rate limiter which implements a token bucket approach. The rate limiter allows bursts of up to 'burst' to exceed the QPS, while still maintaining a smoothed qps rate of 'qps'. The bucket is initially filled with 'burst' tokens, and refills at a rate of 'qps'. The maximum number of tokens in the bucket is capped at 'burst'.
func NewTokenBucketRateLimiterWithClock ¶
func NewTokenBucketRateLimiterWithClock(qps float32, burst int, c Clock) RateLimiter
NewTokenBucketRateLimiterWithClock is identical to NewTokenBucketRateLimiter but allows an injectable clock, for testing.
type RealClock ¶
type RealClock struct{}
RealClock really calls time.Now()
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is an abstraction to make it easy to start and stop groups of things that can be described by a single function which waits on a channel close to exit.
type SafeWaitGroup ¶
type SafeWaitGroup struct {
// contains filtered or unexported fields
}
SafeWaitGroup must not be copied after first use.
func NewSafeWaitGroup ¶
func NewSafeWaitGroup() *SafeWaitGroup
func (*SafeWaitGroup) Add ¶
func (wg *SafeWaitGroup) Add(delta int) error
Add adds delta, which may be negative, similar to sync.WaitGroup. If Add with a positive delta happens after Wait, it will return error, which prevent unsafe Add.
func (*SafeWaitGroup) Reset ¶
func (wg *SafeWaitGroup) Reset()
Wait blocks until the WaitGroup counter is zero.
func (*SafeWaitGroup) Wait ¶
func (wg *SafeWaitGroup) Wait()
Wait blocks until the WaitGroup counter is zero.
type ServerOption ¶
type ServerOption interface {
// contains filtered or unexported methods
}
A ServerOption sets options such as credentials, codec and keepalive parameters, etc.
func SetDebug ¶
func SetDebug() ServerOption
func SetDocPath ¶
func SetDocPath(dir string) ServerOption
func SetProtocol ¶
func SetProtocol(p proto) ServerOption
func SetSecure ¶
func SetSecure(dir, ca, pub, key string) ServerOption