Documentation ¶
Index ¶
- Variables
- type ConnectionOptions
- type Empty
- type HttpClient
- type HttpResponse
- type Mode
- type ReconnectionOptions
- type Socket
- type Ticker
- func (t *Ticker) Close() error
- func (t *Ticker) OnClose(f func(code int, reason string))
- func (t *Ticker) OnConnect(f func())
- func (t *Ticker) OnError(f func(err error))
- func (t *Ticker) OnMessage(f func(messageType int, message []byte))
- func (t *Ticker) OnNoReconnect(f func(attempt int))
- func (t *Ticker) OnReconnect(f func(attempt int, delay time.Duration))
- func (t *Ticker) OnTick(f func(tick interface{}))
- func (t *Ticker) Resubscribe() error
- func (t *Ticker) Serve()
- func (t *Ticker) ServeWithContext(ctx context.Context)
- func (t *Ticker) SetAccessToken(aToken string)
- func (t *Ticker) SetAutoReconnect(val bool)
- func (t *Ticker) SetConnectTimeout(val time.Duration)
- func (t *Ticker) SetMode(mode Mode, tokens []uint32) error
- func (t *Ticker) SetReconnectMaxDelay(val time.Duration) error
- func (t *Ticker) SetReconnectMaxRetries(val int)
- func (t *Ticker) SetRootURL(u url.URL)
- func (t *Ticker) Stop()
- func (t *Ticker) Subscribe(tokens []uint32) error
- func (t *Ticker) Unsubscribe(tokens []uint32) error
Constants ¶
This section is empty.
Variables ¶
var GetResterClient = func(timeout time.Duration) HttpClient { defaultRoundTripper := http.DefaultTransport defaultTransportPointer, ok := defaultRoundTripper.(*http.Transport) if !ok { panic("defaultRoundTripper not an *http.Transport") } defaultTransport := *defaultTransportPointer defaultTransport.MaxIdleConns = 100 defaultTransport.MaxIdleConnsPerHost = 50 defaultTransport.TLSHandshakeTimeout = timeout defaultTransport.DialContext = (&net.Dialer{ Timeout: timeout, KeepAlive: timeout, }).DialContext cookieJar, _ := cookiejar.New(&cookiejar.Options{ PublicSuffixList: publicsuffix.List, }) netClient := &http.Client{ Timeout: timeout, Transport: &defaultTransport, Jar: cookieJar, } return &httpClient{ client: netClient, } }
var GetTimeout = func(confTimeout string, defaultTimeout time.Duration) time.Duration { timeout := defaultTimeout if confTimeout != "" { var err error timeout, err = time.ParseDuration(confTimeout) if err != nil { timeout = defaultTimeout } } return timeout }
Functions ¶
This section is empty.
Types ¶
type ConnectionOptions ¶
type HttpClient ¶
type HttpClient interface { Do(ctx context.Context, method, rURL string, params url.Values, headers http.Header) (*HttpResponse, error) DoRaw(ctx context.Context, method, rURL string, reqBody []byte, headers http.Header) (*HttpResponse, error) DoEnvelope(ctx context.Context, method, url string, params url.Values, headers http.Header, obj interface{}) error DoJSON(ctx context.Context, method, url string, params url.Values, headers http.Header, obj interface{}) (*HttpResponse, error) }
type HttpResponse ¶
HTTPResponse encompasses byte body + the response of an HTTP request.
type Socket ¶
type Socket struct { Conn *websocket.Conn WebsocketDialer *websocket.Dialer Url string ConnectionOptions ConnectionOptions RequestHeader http.Header OnConnected func(socket Socket) OnTextMessage func(message string, socket Socket) OnBinaryMessage func(data []byte, socket Socket) OnConnectError func(err error, socket Socket) OnDisconnected func(err error, socket Socket) OnPingReceived func(data string, socket Socket) OnPongReceived func(data string, socket Socket) IsConnected bool Timeout time.Duration // contains filtered or unexported fields }
func (*Socket) SendBinary ¶
type Ticker ¶
Ticker is a Kite connect ticker instance.
func (*Ticker) Close ¶
Close tries to close the connection gracefully. If the server doesn't close it
func (*Ticker) OnNoReconnect ¶
OnNoReconnect callback.
func (*Ticker) OnReconnect ¶
OnReconnect callback.
func (*Ticker) Resubscribe ¶
Resubscribe resubscribes to the current stored subscriptions
func (*Ticker) Serve ¶
func (t *Ticker) Serve()
Serve starts the connection to ticker server. Since its blocking its recommended to use it in a go routine.
func (*Ticker) ServeWithContext ¶
ServeWithContext starts the connection to ticker server and additionally accepts a context. Since its blocking its recommended to use it in a go routine.
func (*Ticker) SetAccessToken ¶
SetAccessToken set access token.
func (*Ticker) SetAutoReconnect ¶
SetAutoReconnect enable/disable auto reconnect.
func (*Ticker) SetConnectTimeout ¶
SetConnectTimeout sets default timeout for initial connect handshake
func (*Ticker) SetReconnectMaxDelay ¶
SetReconnectMaxDelay sets maximum auto reconnect delay.
func (*Ticker) SetReconnectMaxRetries ¶
SetReconnectMaxRetries sets maximum reconnect attempts.
func (*Ticker) Stop ¶
func (t *Ticker) Stop()
Stop the ticker instance and all the goroutines it has spawned.
func (*Ticker) Unsubscribe ¶
Unsubscribe unsubscribes tick for the given list of tokens.