Documentation
¶
Index ¶
- Variables
- func MergeOptions(opts ...*ably.ClientOptions) *ably.ClientOptions
- func MessagePipe(in <-chan *proto.ProtocolMessage, out chan<- *proto.ProtocolMessage) func(string, *url.URL) (proto.Conn, error)
- func MustQuery(req *http.Request) url.Values
- func NewHTTPClient() *http.Client
- func NewTokenParams(query url.Values) *ably.TokenParams
- func Query(req *http.Request) (url.Values, error)
- func Wait(res ably.Result, err error) error
- type AuthReverseProxy
- type Channel
- type Config
- type Connection
- type CryptoData
- type HostRecorder
- type Key
- type MessageRecorder
- type Namespace
- type Presence
- type ResultGroup
- type RoundTripRecorder
- func (rec *RoundTripRecorder) Hijack(rt http.RoundTripper) http.RoundTripper
- func (rec *RoundTripRecorder) Len() int
- func (rec *RoundTripRecorder) Request(n int) *http.Request
- func (rec *RoundTripRecorder) Requests() []*http.Request
- func (rec *RoundTripRecorder) Reset()
- func (rec *RoundTripRecorder) Response(n int) *http.Response
- func (rec *RoundTripRecorder) Responses() []*http.Response
- func (rec *RoundTripRecorder) RoundTrip(req *http.Request) (*http.Response, error)
- func (rec *RoundTripRecorder) Stop()
- type Sandbox
- func (app *Sandbox) Close() error
- func (app *Sandbox) Key() string
- func (app *Sandbox) KeyParts() (name, secret string)
- func (app *Sandbox) NewRealtimeClient(opts ...*ably.ClientOptions) *ably.RealtimeClient
- func (app *Sandbox) Options(opts ...*ably.ClientOptions) *ably.ClientOptions
- func (app *Sandbox) URL(paths ...string) string
- type StateRecorder
Constants ¶
This section is empty.
Variables ¶
var DefaultLogger = ably.Logger{Level: ably.LogNone}
var Environment = "sandbox"
var NoBinaryProtocol bool
var Timeout = 30 * time.Second
Functions ¶
func MergeOptions ¶
func MergeOptions(opts ...*ably.ClientOptions) *ably.ClientOptions
func MessagePipe ¶
func MessagePipe(in <-chan *proto.ProtocolMessage, out chan<- *proto.ProtocolMessage) func(string, *url.URL) (proto.Conn, error)
func NewHTTPClient ¶
func NewTokenParams ¶
func NewTokenParams(query url.Values) *ably.TokenParams
Types ¶
type AuthReverseProxy ¶
type AuthReverseProxy struct {
TokenQueue []*ably.TokenDetails // when non-nil pops the token from the queue instead querying Ably servers
Listener net.Listener // listener which accepts token request connections
// contains filtered or unexported fields
}
AuthReverseProxy serves token requests by reverse proxying them to the Ably servers. Use URL method for creating values for AuthURL option and Callback method - for AuthCallback ones.
func MustAuthReverseProxy ¶
func MustAuthReverseProxy(opts *ably.ClientOptions) *AuthReverseProxy
MustAuthReverseProxy panics when creating the proxy fails.
func NewAuthReverseProxy ¶
func NewAuthReverseProxy(opts *ably.ClientOptions) (*AuthReverseProxy, error)
NewAuthReverseProxy creates new auth reverse proxy. The given opts are used to create a Auth client, used to reverse proxying token requests.
func (*AuthReverseProxy) Callback ¶
func (srv *AuthReverseProxy) Callback(responseType string) func(*ably.TokenParams) (interface{}, error)
Callback gives new AuthCallback. Available response types are the same as for URL method.
func (*AuthReverseProxy) Close ¶
func (srv *AuthReverseProxy) Close() error
Close makes the proxy server stop accepting connections.
func (*AuthReverseProxy) ServeHTTP ¶
func (srv *AuthReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface.
func (*AuthReverseProxy) URL ¶
func (srv *AuthReverseProxy) URL(responseType string) string
URL gives new AuthURL for the requested responseType. Available response types are:
- "token", which responds with (ably.TokenDetails).Token as a string
- "details", which responds with ably.TokenDetails
- "request", which responds with ably.TokenRequest
type Config ¶
type Config struct {
ID string `json:"id,omitempty"`
AppID string `json:"appId,omitempty"`
AccountID string `json:"accountId,omitempty"`
Status int `json:"status,omitempty"`
Created int `json:"created,omitempty"`
Modified int `json:"modified,omitempty"`
TLSOnly bool `json:"tlsOnly,omitempty"`
Labels string `json:"labels,omitempty"`
Keys []Key `json:"keys"`
Namespaces []Namespace `json:"namespaces"`
Channels []Channel `json:"channels"`
Connections []Connection `json:"connections,omitempty"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
type Connection ¶
type CryptoData ¶
type CryptoData struct {
Algorithm string `json:"algorithm"`
Mode string `json:"mode"`
KeyLen int `json:"keylength"`
Key string `json:"key"`
IV string `json:"iv"`
Items []struct {
Encoded proto.Message `json:"encoded"`
Encrypted proto.Message `json:"encrypted"`
} `json:"items"`
}
func LoadCryptoData ¶
func LoadCryptoData(rel string) (*CryptoData, []byte, []byte, error)
type HostRecorder ¶
type HostRecorder struct {
Hosts map[string]struct{}
// contains filtered or unexported fields
}
func NewRecorder ¶
func NewRecorder(httpClient *http.Client) *HostRecorder
func (*HostRecorder) Options ¶
func (hr *HostRecorder) Options(host string) *ably.ClientOptions
type Key ¶
type Key struct {
ID string `json:"id,omitempty"`
ScopeID string `json:"scopeId,omitempty"`
Status int `json:"status,omitempty"`
Type int `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Created int `json:"created,omitempty"`
Modified int `json:"modified,omitempty"`
RawCapability string `json:"capability,omitempty"`
Expires int `json:"expired,omitempty"`
Privileged bool `json:"privileged,omitempty"`
}
func (*Key) Capability ¶
func (k *Key) Capability() ably.Capability
type MessageRecorder ¶
type MessageRecorder struct {
// contains filtered or unexported fields
}
MessageRecorder
func NewMessageRecorder ¶
func NewMessageRecorder() *MessageRecorder
NewMessageRecorder gives new spy value that records incoming and outgoing ProtocolMessages and dialed endpoints.
For use with Dial field of ClientOptions.
func (*MessageRecorder) Received ¶
func (rec *MessageRecorder) Received() []*proto.ProtocolMessage
Received
type ResultGroup ¶
type ResultGroup struct {
// contains filtered or unexported fields
}
ResultGroup is like sync.WaitGroup, but for ably.Result values.
ResultGroup blocks till last added ably.Result has completed successfully.
If at least ably.Result value failed, ResultGroup returns first encountered error immadiately.
func (*ResultGroup) Wait ¶
func (rg *ResultGroup) Wait() error
type RoundTripRecorder ¶
RoundTripRecorder is a http.Transport wrapper which records HTTP request/response pairs.
func (*RoundTripRecorder) Hijack ¶
func (rec *RoundTripRecorder) Hijack(rt http.RoundTripper) http.RoundTripper
Hijack injects http.Transport into the wrapper.
func (*RoundTripRecorder) Len ¶
func (rec *RoundTripRecorder) Len() int
Len gives number of recorded request/response pairs.
It is save to call Len() before calling Stop().
func (*RoundTripRecorder) Request ¶
func (rec *RoundTripRecorder) Request(n int) *http.Request
Request gives nth recorded http.Request.
func (*RoundTripRecorder) Requests ¶
func (rec *RoundTripRecorder) Requests() []*http.Request
Requests gives all HTTP requests in order they were recorded.
func (*RoundTripRecorder) Reset ¶
func (rec *RoundTripRecorder) Reset()
Reset resets the recorder requests and responses.
func (*RoundTripRecorder) Response ¶
func (rec *RoundTripRecorder) Response(n int) *http.Response
Response gives nth recorded http.Response.
func (*RoundTripRecorder) Responses ¶
func (rec *RoundTripRecorder) Responses() []*http.Response
Responses gives all HTTP responses in order they were recorded.
func (*RoundTripRecorder) Stop ¶
func (rec *RoundTripRecorder) Stop()
Stop makes the recorder stop recording new requests/responses.
type Sandbox ¶
func MustSandbox ¶
func NewRealtimeClient ¶
func NewRealtimeClient(opts *ably.ClientOptions) (*Sandbox, *ably.RealtimeClient)
func NewRestClient ¶
func NewRestClient(opts *ably.ClientOptions) (*Sandbox, *ably.RestClient)
func NewSandbox ¶
func (*Sandbox) NewRealtimeClient ¶
func (app *Sandbox) NewRealtimeClient(opts ...*ably.ClientOptions) *ably.RealtimeClient
func (*Sandbox) Options ¶
func (app *Sandbox) Options(opts ...*ably.ClientOptions) *ably.ClientOptions
type StateRecorder ¶
type StateRecorder struct {
Timeout time.Duration // times out waiting for states after this duration; 15s by default
// contains filtered or unexported fields
}
StateRecorder provides:
- send ably.State channel for recording state transitions
- goroutine-safe access to recorded state enums
func NewStateChanRecorder ¶
func NewStateChanRecorder(buffer int) *StateRecorder
NewStateChanRecorder gives new recorder which records channel-related state transitions only.
func NewStateConnRecorder ¶
func NewStateConnRecorder(buffer int) *StateRecorder
NewStateConnRecorder gives new recorder which records connection-related state transitions only.
func NewStateRecorder ¶
func NewStateRecorder(buffer int) *StateRecorder
NewStateRecorder gives new recorder which purpose is to record states via (*ClientOptions).Listener channel.
If buffer is > 0, the recorder will use it as a buffer to ensure all states transitions are received. If buffer is <= 0, the recorder will not buffer any states, which can result in some of them being dropped.
func (*StateRecorder) Add ¶
func (rec *StateRecorder) Add(state ably.StateEnum)
Add appends state to the list of recorded ones, used to ensure ordering of the states by injecting values at certain points of the test.
func (*StateRecorder) Channel ¶
func (rec *StateRecorder) Channel() chan<- ably.State
func (*StateRecorder) Errors ¶
func (rec *StateRecorder) Errors() []error
Errors gives copy of the error that recorded events hold. It returns only non-nil errors. If none of the recorded states contained an error, the method returns nil.
func (*StateRecorder) States ¶
func (rec *StateRecorder) States() []ably.StateEnum
States gives copy of the recorded states, safe for use while the recorder is still running.
func (*StateRecorder) Stop ¶
func (rec *StateRecorder) Stop()
Stop stops separate recording gorouting and waits until it terminates.