Documentation ¶
Overview ¶
Package kite is a library for creating micro-services. Two main types implemented by this package are Kite for creating a micro-service server called "Kite" and Client for communicating with another kites.
kontrolclient implements a kite.Client for interacting with Kontrol kite.
Package server implements a HTTP(S) server for kites.
Index ¶
- Constants
- Variables
- func Close(kites interface{}) error
- func Closer(kites interface{}) io.Closer
- func NewWebRCTHandler() *webRTCHandler
- type Auth
- type Client
- func (c *Client) Close()
- func (c *Client) Dial() (err error)
- func (c *Client) DialForever() (connected chan bool, err error)
- func (c *Client) DialTimeout(timeout time.Duration) error
- func (c *Client) Go(method string, args ...interface{}) chan *response
- func (c *Client) GoWithTimeout(method string, timeout time.Duration, args ...interface{}) chan *response
- func (c *Client) OnConnect(handler func())
- func (c *Client) OnDisconnect(handler func())
- func (c *Client) OnTokenExpire(handler func())
- func (c *Client) OnTokenRenew(handler func(token string))
- func (c *Client) RemoteAddr() string
- func (c *Client) SendWebRTCRequest(req *protocol.WebRTCSignalMessage) error
- func (c *Client) SetUsername(username string)
- func (c *Client) Tell(method string, args ...interface{}) (result *dnode.Partial, err error)
- func (c *Client) TellWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error)
- type ErrClose
- type Error
- type FinalFunc
- type Handler
- type HandlerFunc
- type Kite
- func (k *Kite) Addr() string
- func (k *Kite) AuthenticateFromKiteKey(r *Request) error
- func (k *Kite) AuthenticateFromToken(r *Request) error
- func (k *Kite) AuthenticateSimpleKiteKey(key string) (string, error)
- func (k *Kite) Close()
- func (k *Kite) FinalFunc(f FinalFunc)
- func (k *Kite) GetKey() (string, error)
- func (k *Kite) GetKites(query *protocol.KontrolQuery) ([]*Client, error)
- func (k *Kite) GetToken(kite *protocol.Kite) (string, error)
- func (k *Kite) GetTokenForce(kite *protocol.Kite) (string, error)
- func (k *Kite) Handle(method string, handler Handler) *Method
- func (k *Kite) HandleFunc(method string, handler HandlerFunc) *Method
- func (k *Kite) HandleHTTP(pattern string, handler http.Handler)
- func (k *Kite) HandleHTTPFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (k *Kite) Kite() *protocol.Kite
- func (k *Kite) KiteKey() string
- func (k *Kite) KontrolKey() *rsa.PublicKey
- func (k *Kite) KontrolReadyNotify() chan struct{}
- func (k *Kite) NewClient(remoteURL string) *Client
- func (k *Kite) NewKeyRenewer(interval time.Duration)
- func (k *Kite) OnConnect(handler func(*Client))
- func (k *Kite) OnDisconnect(handler func(*Client))
- func (k *Kite) OnFirstRequest(handler func(*Client))
- func (k *Kite) OnRegister(handler func(*protocol.RegisterResult))
- func (k *Kite) Port() int
- func (k *Kite) PostHandle(handler Handler)
- func (k *Kite) PostHandleFunc(handler HandlerFunc)
- func (k *Kite) PreHandle(handler Handler)
- func (k *Kite) PreHandleFunc(handler HandlerFunc)
- func (k *Kite) RSAKey(token *jwt.Token) (interface{}, error)
- func (k *Kite) Register(kiteURL *url.URL) (*registerResult, error)
- func (k *Kite) RegisterForever(kiteURL *url.URL) error
- func (k *Kite) RegisterHTTP(kiteURL *url.URL) (*registerResult, error)
- func (k *Kite) RegisterHTTPForever(kiteURL *url.URL)
- func (k *Kite) RegisterToProxy(registerURL *url.URL, query *protocol.KontrolQuery)
- func (k *Kite) RegisterToTunnel()
- func (k *Kite) RegisterURL(local bool) *url.URL
- func (k *Kite) Run()
- func (k *Kite) SendWebRTCRequest(req *protocol.WebRTCSignalMessage) error
- func (k *Kite) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (k *Kite) ServerCloseNotify() chan bool
- func (k *Kite) ServerReadyNotify() chan bool
- func (k *Kite) SetupKontrolClient() error
- func (k *Kite) SetupSignalHandler()
- func (k *Kite) TellKontrolWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error)
- func (k *Kite) UseTLS(certPEM, keyPEM string)
- func (k *Kite) UseTLSFile(certFile, keyFile string)
- type Level
- type Logger
- type Method
- func (m *Method) DisableAuthentication() *Method
- func (m *Method) FinalFunc(f FinalFunc) *Method
- func (m *Method) PostHandle(handler Handler) *Method
- func (m *Method) PostHandleFunc(handler HandlerFunc) *Method
- func (m *Method) PreHandle(handler Handler) *Method
- func (m *Method) PreHandleFunc(handler HandlerFunc) *Method
- func (m *Method) ServeKite(r *Request) (interface{}, error)
- func (m *Method) Throttle(fillInterval time.Duration, capacity int64) *Method
- type MethodHandling
- type Request
- type Response
- type TokenRenewer
Constants ¶
const WebRTCHandlerName = "kite.handleWebRTC"
WebRTCHandlerName provides the naming scheme for the handler
Variables ¶
var ErrKeyNotTrusted = errors.New("kontrol key is not trusted")
ErrKeyNotTrusted is returned by verify functions when the key should not be trusted.
var ErrNoKitesAvailable = errors.New("no kites availabile")
Returned from GetKites when query matches no kites.
Functions ¶
func Close ¶
func Close(kites interface{}) error
Close is a wrapper for Closer that calls a Close on it.
func Closer ¶
Closer returns a io.Closer that can be used to close all the kites given by the generic argument.
The kites is expected to be one of:
- *kite.Kite
- []*kite.Kite
- *kite.Client
- []*kite.Client
If the kites argument is a slice and at least one of the kites returns error on Close, the Close method returns *ErrClose.
TODO(rjeczalik): Currently (*Kite).Close and (*Client).Close does not implement io.Closer interface - when [0] is resolved, this method should be adopted accordingly.
[0] - https://github.com/koding/kite/issues/183
func NewWebRCTHandler ¶
func NewWebRCTHandler() *webRTCHandler
NewWebRCTHandler creates a new handler for web rtc signalling services.
Types ¶
type Auth ¶
type Auth struct { // Type can be "kiteKey", "token" or "sessionID" for now. Type string `json:"type"` Key string `json:"key"` }
Authentication is used when connecting a Client.
type Client ¶
type Client struct { protocol.Kite // remote kite information // LocalKite references to the kite which owns the client // connection. LocalKite *Kite // Auth is a credential used to authenticate with a remote kite. // // Required if remote kite requires authentication. Auth *Auth // Reconnect says whether we should reconnect with a new // session when an old one got invalidated or the connection // broke. Reconnect bool // URL specifies the SockJS URL of the remote kite. URL string // Config is used when setting up client connection to // the remote kite. // // If Config is nil, LocalKite.Config is used instead. Config *config.Config // Concurrent specified whether we should process incoming messages concurrently. // // Defaults to true. Concurrent bool // ConcurrentCallbacks, when true, makes execution of callbacks in // incoming messages concurrent. This may result in a callback // received in an earlier message to be executed after a callback // from a new meesage - no order is guaranteed, it's up to Go scheduler. // // By default this field is false to be backward-compatible with // go1.4 scheduling behaviour. ConcurrentCallbacks bool // ClientFunc is called each time new sockjs.Session is established. // The session will use returned *http.Client for HTTP round trips // for XHR transport. // // If ClientFunc is nil, sockjs.Session will use default, internal // *http.Client value. // // Deprecated: Set Config.XHR of the local kite, that // owns this connection, insead. ClientFunc func(*sockjsclient.DialOptions) *http.Client // ReadBufferSize is the input buffer size. By default it's 4096. // // Deprecated: Set Config.Websocket.ReadBufferSize of the local kite, // that owns this connection, instead. ReadBufferSize int // WriteBufferSize is the output buffer size. By default it's 4096. // // Deprecated: Set Config.Websocket.WriteBufferSize of the local kite, // that owns this connection, instead. WriteBufferSize int // contains filtered or unexported fields }
Client is the client for communicating with another Kite. It has Tell() and Go() methods for calling methods sync/async way.
func (*Client) DialForever ¶
Dial connects to the remote Kite. If it can't connect, it retries indefinitely. It returns a channel to check if it's connected or not.
func (*Client) DialTimeout ¶
DialTimeout acts like Dial but takes a timeout.
func (*Client) Go ¶
Go makes an unblocking method call to the server. It returns a channel that the caller can wait on it to get the response.
func (*Client) GoWithTimeout ¶
func (c *Client) GoWithTimeout(method string, timeout time.Duration, args ...interface{}) chan *response
GoWithTimeout does the same thing with Go() method except it takes an extra argument that is the timeout for waiting reply from the remote Kite. If timeout is given 0, the behavior is same as Go().
func (*Client) OnConnect ¶
func (c *Client) OnConnect(handler func())
OnConnect adds a callback which is called when client connects to a remote kite.
func (*Client) OnDisconnect ¶
func (c *Client) OnDisconnect(handler func())
OnDisconnect adds a callback which is called when client disconnects from a remote kite.
func (*Client) OnTokenExpire ¶
func (c *Client) OnTokenExpire(handler func())
OnTokenExpire adds a callback which is called when client receives token-is-expired error from a remote kite.
func (*Client) OnTokenRenew ¶
OnTokenRenew adds a callback which is called when client successfully renews its token.
func (*Client) RemoteAddr ¶
func (*Client) SendWebRTCRequest ¶
func (c *Client) SendWebRTCRequest(req *protocol.WebRTCSignalMessage) error
SendWebRTCRequest sends requests to kontrol for signalling purposes.
func (*Client) SetUsername ¶
func (*Client) Tell ¶
Tell makes a blocking method call to the server. Waits until the callback function is called by the other side and returns the result and the error.
func (*Client) TellWithTimeout ¶
func (c *Client) TellWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error)
TellWithTimeout does the same thing with Tell() method except it takes an extra argument that is the timeout for waiting reply from the remote Kite. If timeout is given 0, the behavior is same as Tell().
type ErrClose ¶
type ErrClose struct { // Errs has always length of the slice passed to the Close function. // It contains at least one non-nil error. Errs []error }
ErrClose is returned by the Close function, when the argument passed to it was a slice of kites.
type Error ¶
type Error struct { Type string `json:"type"` Message string `json:"message"` CodeVal string `json:"code"` RequestID string `json:"id"` }
Error is the type of the kite related errors returned from kite package.
type FinalFunc ¶
FinalFunc represents a proxy function that is called last in the method call chain, regardless whether whole call chained succeeded with non-nil error or not.
type Handler ¶
Objects implementing the Handler interface can be registered to a method. The returned result must be marshalable with json package.
type HandlerFunc ¶
HandlerFunc is a type adapter to allow the use of ordinary functions as Kite handlers. If h is a function with the appropriate signature, HandlerFunc(h) is a Handler object that calls h.
func (HandlerFunc) ServeKite ¶
func (h HandlerFunc) ServeKite(r *Request) (interface{}, error)
ServeKite calls h(r)
type Kite ¶
type Kite struct { Config *config.Config // Log logs with the given Logger interface Log Logger // SetLogLevel changes the level of the logger. Default is INFO. SetLogLevel func(Level) // Contains different functions for authenticating user from request. // Keys are the authentication types (options.auth.type). Authenticators map[string]func(*Request) error // ClientFunc is used as the default value for kite.Client.ClientFunc. // If nil, a default ClientFunc will be used. // // Deprecated: Set Config.XHR field instead. ClientFunc func(*sockjsclient.DialOptions) *http.Client // WebRTCHandler handles the webrtc responses coming from a signalling server. WebRTCHandler Handler // MethodHandling defines how the kite is returning the response for // multiple handlers MethodHandling MethodHandling TLSConfig *tls.Config Id string // Unique kite instance id // contains filtered or unexported fields }
Kite defines a single process that enables distributed service messaging amongst the peers it is connected. A Kite process acts as a Client and as a Server. That means it can receive request, process them, but it also can make request to other kites.
Do not use this struct directly. Use kite.New function, add your handlers with HandleFunc mehtod, then call Run method to start the inbuilt server (or pass it to any http.Handler compatible server)
func New ¶
New creates, initializes and then returns a new Kite instance.
Version must be in 3-digit semantic form.
Name is important that it's also used to be searched by others.
func NewWithConfig ¶
NewWithConfig builds a new kite value for the given configuration.
func (*Kite) AuthenticateFromKiteKey ¶
AuthenticateFromKiteKey authenticates user from kite key.
func (*Kite) AuthenticateFromToken ¶
AuthenticateFromToken is the default Authenticator for Kite.
func (*Kite) AuthenticateSimpleKiteKey ¶
AuthenticateSimpleKiteKey authenticates user from the given kite key and returns the authenticated username. It's the same as AuthenticateFromKiteKey but can be used without the need for a *kite.Request.
func (*Kite) FinalFunc ¶
FinalFunc registers a function that is always called as a last one after pre-, handler and post- functions.
It receives a result and an error from last handler that got executed prior to calling final func.
func (*Kite) GetKey ¶
GetKey is used to get a new public key from kontrol if the current one is invalidated. The key is also replaced in memory and every request is going to use it. This means even if kite.key contains the old key, the kite itself uses the new one.
func (*Kite) GetKites ¶
func (k *Kite) GetKites(query *protocol.KontrolQuery) ([]*Client, error)
GetKites returns the list of Kites matching the query. The returned list contains Ready to connect Client instances. The caller must connect with Client.Dial() before using each Kite. An error is returned when no kites are available.
The returned clients have token renewer running, which is leaked when a single *Client is not closed. A handy utility to ease closing the clients is a Close function:
clients, err := k.GetKites(&protocol.KontrolQuery{Name: "foo"}) if err != nil { panic(err) } // If we want to only use the first result and discard the rest, // we need to close the rest explicitly. defer kite.Close(clients[1:]) return clients[0]
func (*Kite) GetToken ¶
GetToken is used to get a token for a single Kite.
In case of calling GetToken multiple times, it usually returns the same token until it expires on Kontrol side.
func (*Kite) GetTokenForce ¶
GetTokenForce is used to obtain a new token for the given kite.
It always returns a new token and forces a Kontrol to forget about any previous ones.
func (*Kite) Handle ¶
Handle registers the handler for the given method. The handler is called when a method call is received from a Kite.
func (*Kite) HandleFunc ¶
func (k *Kite) HandleFunc(method string, handler HandlerFunc) *Method
HandleFunc registers a handler to run when a method call is received from a Kite. It returns a *Method option to further modify certain options on a method call
func (*Kite) HandleHTTP ¶
HandleHTTP registers the HTTP handler for the given pattern into the underlying HTTP muxer.
func (*Kite) HandleHTTPFunc ¶
HandleHTTPFunc registers the HTTP handler for the given pattern into the underlying HTTP muxer.
func (*Kite) KontrolKey ¶
KontrolKey gives a Kontrol's public key.
The value is taken form kite key's kontrolKey claim.
func (*Kite) KontrolReadyNotify ¶
func (k *Kite) KontrolReadyNotify() chan struct{}
KontrolReadyNotify returns a channel that is closed when a successful registration to kontrol is done.
func (*Kite) NewClient ¶
NewClient returns a pointer to a new Client. The returned instance is not connected. You have to call Dial() or DialForever() before calling Tell() and Go() methods.
func (*Kite) NewKeyRenewer ¶
NewKeyRenewer renews the internal key every given interval
func (*Kite) OnConnect ¶
OnConnect registers a callbacks which is called when a Kite connects to the k Kite.
func (*Kite) OnDisconnect ¶
OnDisconnect registers a function to run when a connected Kite is disconnected.
func (*Kite) OnFirstRequest ¶
OnFirstRequest registers a function to run when we receive first request from other Kite.
func (*Kite) OnRegister ¶
func (k *Kite) OnRegister(handler func(*protocol.RegisterResult))
OnRegister registers a callback which is called when a Kite registers to a Kontrol.
func (*Kite) Port ¶
Port returns the TCP port number that the kite listens. Port must be called after the listener is initialized. You can use ServerReadyNotify function to get notified when listener is ready.
Kite starts to listen the port when Run() is called. Since Run() is blocking you need to run it as a goroutine the call this function when listener is ready.
Example:
k := kite.New("x", "1.0.0") go k.Run() <-k.ServerReadyNotify() port := k.Port()
func (*Kite) PostHandle ¶
PostHandle registers an handler which is executed after a kite.Handler method is executed. Calling PostHandler multiple times registers multiple handlers. A non-error return triggers the execution of the next handler. The execution order is FIFO.
func (*Kite) PostHandleFunc ¶
func (k *Kite) PostHandleFunc(handler HandlerFunc)
PostHandleFunc is the same as PostHandle. It accepts a HandlerFunc.
func (*Kite) PreHandle ¶
PreHandle registers an handler which is executed before a kite.Handler method is executed. Calling PreHandle multiple times registers multiple handlers. A non-error return triggers the execution of the next handler. The execution order is FIFO.
func (*Kite) PreHandleFunc ¶
func (k *Kite) PreHandleFunc(handler HandlerFunc)
PreHandleFunc is the same as PreHandle. It accepts a HandlerFunc.
func (*Kite) RSAKey ¶
RSAKey returns the corresponding public key for the issuer of the token. It is called by jwt-go package when validating the signature in the token.
func (*Kite) Register ¶
Register registers current Kite to Kontrol. After registration other Kites can find it via GetKites() or WatchKites() method. This method does not handle the reconnection case. If you want to keep registered to kontrol, use RegisterForever().
func (*Kite) RegisterForever ¶
RegisterForever is equivalent to Register(), but it tries to re-register if there is a disconnection. The returned error is for the first register attempt. It returns nil if ReadNotify() is ready and it's registered successful.
func (*Kite) RegisterHTTP ¶
RegisterHTTP registers current Kite to Kontrol. After registration other Kites can find it via GetKites() or WatchKites() method. It registers again if connection to kontrol is lost.
func (*Kite) RegisterHTTPForever ¶
RegisterHTTPForever is just like RegisterHTTP however it first tries to register forever until a response from kontrol is received. It's useful to use it during app initializations. After the registration a reconnect is automatically handled inside the RegisterHTTP method.
func (*Kite) RegisterToProxy ¶
func (k *Kite) RegisterToProxy(registerURL *url.URL, query *protocol.KontrolQuery)
RegisterToProxy is just like RegisterForever but registers the given URL to kontrol over a kite-proxy. A Kiteproxy is a reverseproxy that can be used for SSL termination or handling hundreds of kites behind a single. This is a blocking function.
func (*Kite) RegisterToTunnel ¶
func (k *Kite) RegisterToTunnel()
RegisterToTunnel finds a tunnel proxy kite by asking kontrol then registers itself on proxy. On error, retries forever. On every successful registration, it sends the proxied URL to the registerChan channel. There is no register URL needed because the Tunnel Proxy automatically gets the IP from tunneling. This is a blocking function.
func (*Kite) RegisterURL ¶
RegisterURL returns a URL that is either local or public. It's an helper method to get a Registration URL that can be passed to Kontrol (via the methods Register(), RegisterToProxy(), etc.) It needs to be called after all configurations are done (like TLS, Port,etc.). If local is true a local IP is used, otherwise a public IP is being used.
func (*Kite) Run ¶
func (k *Kite) Run()
Run is a blocking method. It runs the kite server and then accepts requests asynchronously. It supports graceful restart via SIGUSR2.
func (*Kite) SendWebRTCRequest ¶
func (k *Kite) SendWebRTCRequest(req *protocol.WebRTCSignalMessage) error
SendWebRTCRequest sends requests to kontrol for signalling purposes.
func (*Kite) ServeHTTP ¶
func (k *Kite) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP helps Kite to satisfy the http.Handler interface. So kite can be used as a standard http server.
func (*Kite) ServerCloseNotify ¶
func (*Kite) ServerReadyNotify ¶
func (*Kite) SetupKontrolClient ¶
SetupKontrolClient setups and prepares a the kontrol instance. It connects to kontrol and reconnects again if there is any disconnections. This method is called internally whenever a kontrol client specific action is taking. However if you wish to connect earlier you may call this method.
func (*Kite) SetupSignalHandler ¶
func (k *Kite) SetupSignalHandler()
SetupSignalHandler listens to signals and toggles the log level to DEBUG mode when it received a SIGUSR2 signal. Another SIGUSR2 toggles the log level back to the old level.
func (*Kite) TellKontrolWithTimeout ¶
func (k *Kite) TellKontrolWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error)
TellKontrolWithTimeout is a lower level function for communicating directly with kontrol. Like GetKites and GetToken, this automatically sets up and connects to kontrol as needed.
func (*Kite) UseTLSFile ¶
type Logger ¶
type Logger interface { // Fatal logs to the FATAL, ERROR, WARNING, INFO and DEBUG levels, // including a stack trace of all running goroutines, then calls // os.Exit(1). Fatal(format string, args ...interface{}) // Error logs to the ERROR, WARNING, INFO and DEBUG level. Error(format string, args ...interface{}) // Warning logs to the WARNING, INFO and DEBUG level. Warning(format string, args ...interface{}) // Info logs to the INFO and DEBUG level. Info(format string, args ...interface{}) // Debug logs to the DEBUG level. Debug(format string, args ...interface{}) }
Logger is the interface used to log messages in different levels.
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method defines a method and the Handler it is bind to. By default "ReturnMethod" handling is used.
func (*Method) DisableAuthentication ¶
DisableAuthentication disables authentication check for this method.
func (*Method) FinalFunc ¶
FinalFunc registers a function that is always called as a last one after pre-, handler and post- functions for the given method.
It receives a result and an error from last handler that got executed prior to calling final func.
func (*Method) PostHandle ¶
PostHandle adds a new kite handler which is executed after the method.
func (*Method) PostHandleFunc ¶
func (m *Method) PostHandleFunc(handler HandlerFunc) *Method
PostHandlerFunc adds a new kite handlerfunc which is executed before the method.
func (*Method) PreHandleFunc ¶
func (m *Method) PreHandleFunc(handler HandlerFunc) *Method
PreHandlerFunc adds a new kite handlerfunc which is executed before the method.
func (*Method) Throttle ¶
Throttle throttles the method for each incoming request. The throttle algorithm is based on token bucket implementation: http://en.wikipedia.org/wiki/Token_bucket. Rate determines the number of request which are allowed per frequency. Example: A capacity of 50 and fillInterval of two seconds means that initially it can handle 50 requests and every two seconds the bucket will be filled with one token until it hits the capacity. If there is a burst API calls, all tokens will be exhausted and clients need to be wait until the bucket is filled with time. For example to have throttle with 30 req/second, you need to have a fillinterval of 33.33 milliseconds.
type MethodHandling ¶
type MethodHandling int
MethodHandling defines how to handle chaining of kite.Handler middlewares. An error breaks the chain regardless of what handling is used. Note that all Pre and Post handlers are executed regardless the handling logic, only the return paramater is defined by the handling mode.
const ( // ReturnMethod returns main method's response. This is the standard default. ReturnMethod MethodHandling = iota // ReturnFirst returns the first non-nil response. ReturnFirst // ReturnLatest returns the latest response (waterfall behaviour) ReturnLatest )
type Request ¶
type Request struct { // ID is an unique string, which may be used for tracing the request. ID string // Method defines the method name which is invoked by the incoming request. Method string // Username defines the username which the incoming request is bound to. // This is authenticated and validated if authentication is enabled. Username string // Args defines the incoming arguments for the given method. Args *dnode.Partial // LocalKite defines a context for the local kite. LocalKite *Kite // Client defines a context for the remote kite. Client *Client // Auth stores the authentication information for the incoming request and // the type of authentication. This is not used when authentication is disabled. Auth *Auth // Context holds a context that used by the current ServeKite handler. Any // items added to the Context can be fetched from other handlers in the // chain. This is useful with PreHandle and PostHandle handlers to pass // data between handlers. // // The context is canceled when client has disconnected or session // was prematurely terminated. Context context.Context }
Request contains information about the incoming request.
type Response ¶
type Response struct { Error *Error `json:"error" dnode:"-"` Result interface{} `json:"result"` }
Response is the type of the object that is returned from request handlers and the type of only argument that is passed to callback functions.
type TokenRenewer ¶
type TokenRenewer struct {
// contains filtered or unexported fields
}
TokenRenewer renews the token of a Client just before it expires.
func NewTokenRenewer ¶
func NewTokenRenewer(r *Client, k *Kite) (*TokenRenewer, error)
func (*TokenRenewer) RenewWhenExpires ¶
func (t *TokenRenewer) RenewWhenExpires()
RenewWhenExpires renews the token before it expires.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package config contains a Config struct for kites.
|
Package config contains a Config struct for kites. |
Package dnode implements a dnode scrubber.
|
Package dnode implements a dnode scrubber. |
examples
|
|
Command line tool for using kite services.
|
Command line tool for using kite services. |
Package kitekey provides method for reading and writing kite.key file.
|
Package kitekey provides method for reading and writing kite.key file. |
Package protocol defines the communication between the components of the Kite infrastructure.
|
Package protocol defines the communication between the components of the Kite infrastructure. |
Package systeminfo provides a way of getting memory usage, disk usage and various information about the host.
|
Package systeminfo provides a way of getting memory usage, disk usage and various information about the host. |
Package testkeys contains RSA keys and TLS certificates for using in examples and tests.
|
Package testkeys contains RSA keys and TLS certificates for using in examples and tests. |
Package testutil provides a default Kontrol kites for using in tests.
|
Package testutil provides a default Kontrol kites for using in tests. |