Documentation ¶
Overview ¶
Package kuzzle provides a Kuzzle Entry point and main struct for the entire SDK
Index ¶
- Constants
- type Kuzzle
- func (k *Kuzzle) AddListener(event int, channel chan<- json.RawMessage)
- func (k *Kuzzle) AutoQueue() bool
- func (k *Kuzzle) AutoReconnect() bool
- func (k *Kuzzle) AutoReplay() bool
- func (k *Kuzzle) AutoResubscribe() bool
- func (k *Kuzzle) Connect() error
- func (k *Kuzzle) Disconnect() error
- func (k *Kuzzle) EmitEvent(e int, arg interface{})
- func (k *Kuzzle) FlushQueue()
- func (k *Kuzzle) Jwt() string
- func (k *Kuzzle) ListenerCount(event int) int
- func (k *Kuzzle) OfflineQueue() []*types.QueryObject
- func (k *Kuzzle) OfflineQueueLoader() OfflineQueueLoader
- func (k *Kuzzle) On(event int, channel chan<- json.RawMessage)
- func (k *Kuzzle) Once(event int, channel chan<- json.RawMessage)
- func (k *Kuzzle) PlayQueue()
- func (k *Kuzzle) Query(query *types.KuzzleRequest, options types.QueryOptions, ...)
- func (k *Kuzzle) QueueFilter() QueueFilter
- func (k *Kuzzle) QueueMaxSize() int
- func (k *Kuzzle) QueueTTL() time.Duration
- func (k *Kuzzle) ReconnectionDelay() time.Duration
- func (k *Kuzzle) RegisterSub(channel, roomId string, filters json.RawMessage, subscribeToSelf bool, ...)
- func (k *Kuzzle) RemoveAllListeners(event int)
- func (k *Kuzzle) RemoveListener(event int, channel chan<- json.RawMessage)
- func (k *Kuzzle) ReplayInterval() time.Duration
- func (k *Kuzzle) SetAutoQueue(v bool)
- func (k *Kuzzle) SetAutoReplay(v bool)
- func (k *Kuzzle) SetJwt(token string)
- func (k *Kuzzle) SetOfflineQueueLoader(v OfflineQueueLoader)
- func (k *Kuzzle) SetQueueFilter(v QueueFilter)
- func (k *Kuzzle) SetQueueMaxSize(v int)
- func (k *Kuzzle) SetQueueTTL(v time.Duration)
- func (k *Kuzzle) SetReplayInterval(v time.Duration)
- func (k *Kuzzle) SetVolatile(v types.VolatileData)
- func (k *Kuzzle) SslConnection() bool
- func (k *Kuzzle) StartQueuing()
- func (k *Kuzzle) StopQueuing()
- func (k *Kuzzle) UnregisterSub(roomId string)
- func (k *Kuzzle) UnsetJwt()
- func (k *Kuzzle) Volatile() types.VolatileData
- type KuzzleEventEmitter
- type OfflineQueueLoader
- type QueueFilter
Examples ¶
Constants ¶
const (
MAX_CONNECT_RETRY = 10
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kuzzle ¶
type Kuzzle struct { RequestHistory map[string]time.Time MemoryStorage *ms.Ms Security *security.Security Realtime *realtime.Realtime Auth *auth.Auth Server *server.Server Document *document.Document Index *index.Index Collection *collection.Collection // contains filtered or unexported fields }
func (*Kuzzle) AddListener ¶
func (k *Kuzzle) AddListener(event int, channel chan<- json.RawMessage)
AddListener Adds a listener to a Kuzzle global event. When an event is fired, listeners are called in the order of their insertion.
func (*Kuzzle) AutoReconnect ¶
AutoReconnect returns the Kuzzle socket AutoReconnect field value
func (*Kuzzle) AutoReplay ¶
AutoReplay returns the Kuzzle socket AutoReplay field value
func (*Kuzzle) AutoResubscribe ¶
AutoResubscribe returns the Kuzzle socket AutoQueue field value
func (*Kuzzle) Connect ¶
Connect connects to a Kuzzle instance.
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" "github.com/kuzzleio/sdk-go/types" ) func main() { opts := types.NewOptions() conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(conn, opts) err := k.Connect() if err != nil { fmt.Println(err.Error()) return } }
Output:
func (*Kuzzle) Disconnect ¶
Disconnect from Kuzzle and invalidate this instance. Does not fire a disconnected event.
Example ¶
conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := NewKuzzle(conn, nil) err := k.Disconnect() if err != nil { fmt.Println(err.Error()) }
Output:
func (*Kuzzle) FlushQueue ¶
func (k *Kuzzle) FlushQueue()
FlushQueue empties the offline queue without replaying it.
Example ¶
conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := NewKuzzle(conn, nil) k.FlushQueue()
Output:
func (*Kuzzle) Jwt ¶
Jwt get internal jwtToken used to request kuzzle.
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(conn, nil) jwt := k.Jwt() fmt.Println(jwt) }
Output:
func (*Kuzzle) ListenerCount ¶
func (*Kuzzle) OfflineQueue ¶
func (k *Kuzzle) OfflineQueue() []*types.QueryObject
OfflineQueue returns the Kuzzle socket OfflineQueue field value
func (*Kuzzle) OfflineQueueLoader ¶
func (k *Kuzzle) OfflineQueueLoader() OfflineQueueLoader
OfflineQueueLoader returns the Kuzzle socket OfflineQueueLoader field value
func (*Kuzzle) On ¶
func (k *Kuzzle) On(event int, channel chan<- json.RawMessage)
On is an alias to the AddListener function
func (*Kuzzle) PlayQueue ¶
func (k *Kuzzle) PlayQueue()
PlayQueue replays the requests queued during offline mode.
func (*Kuzzle) Query ¶
func (k *Kuzzle) Query(query *types.KuzzleRequest, options types.QueryOptions, responseChannel chan<- *types.KuzzleResponse)
Query this is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
Example ¶
package main import ( "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" "github.com/kuzzleio/sdk-go/types" ) func main() { conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(conn, nil) request := types.KuzzleRequest{Controller: "server", Action: "now"} resChan := make(chan *types.KuzzleResponse) k.Query(&request, nil, resChan) now := <-resChan if now.Error.Message != "" { fmt.Println(now.Error.Message) return } fmt.Println(now.Result) }
Output:
func (*Kuzzle) QueueFilter ¶
func (k *Kuzzle) QueueFilter() QueueFilter
QueueFilter returns the Kuzzle socket QueueFilter field value
func (*Kuzzle) QueueMaxSize ¶
QueueMaxSize returns the Kuzzle socket QueueMaxSize field value
func (*Kuzzle) ReconnectionDelay ¶
ReconnectionDelay returns the Kuzzle socket ReconnectionDelay field value
func (*Kuzzle) RegisterSub ¶
func (k *Kuzzle) RegisterSub(channel, roomId string, filters json.RawMessage, subscribeToSelf bool, notifChan chan<- types.NotificationResult, onReconnectChannel chan<- interface{})
func (*Kuzzle) RemoveAllListeners ¶
RemoveAllListeners removes all listener by event type or all listener if event == -1
func (*Kuzzle) RemoveListener ¶
func (k *Kuzzle) RemoveListener(event int, channel chan<- json.RawMessage)
RemoveListener removes a listener
func (*Kuzzle) ReplayInterval ¶
ReplayInterval returns the Kuzzle socket ReplayInterval field value
func (*Kuzzle) SetAutoQueue ¶
SetAutoQueue sets the Kuzzle socket AutoQueue field with the given value
func (*Kuzzle) SetAutoReplay ¶
SetAutoReplay sets the Kuzzle socket AutoReplay field with the given value
func (*Kuzzle) SetOfflineQueueLoader ¶
func (k *Kuzzle) SetOfflineQueueLoader(v OfflineQueueLoader)
SetOfflineQueueLoader sets the Kuzzle socket OfflineQueueLoader field with given value
func (*Kuzzle) SetQueueFilter ¶
func (k *Kuzzle) SetQueueFilter(v QueueFilter)
SetQueueFilter sets the Kuzzle socket QueueFilter field with given value
func (*Kuzzle) SetQueueMaxSize ¶
SetQueueMaxSize sets the Kuzzle socket QueueMaxSize field with the given value
func (*Kuzzle) SetQueueTTL ¶
SetQueueTTL sets the Kuzzle socket QueueTTL field with the given value
func (*Kuzzle) SetReplayInterval ¶
SetReplayInterval sets the Kuzzle socket ReplayInterval field with the given value
func (*Kuzzle) SetVolatile ¶
func (k *Kuzzle) SetVolatile(v types.VolatileData)
func (*Kuzzle) SslConnection ¶
SslConnection returns the Kuzzle socket SslConnection field value
func (*Kuzzle) StartQueuing ¶
func (k *Kuzzle) StartQueuing()
StartQueuing start the requests queuing.
func (*Kuzzle) UnregisterSub ¶
func (*Kuzzle) UnsetJwt ¶
func (k *Kuzzle) UnsetJwt()
UnsetJwt unset the authentication token and cancel all subscriptions
Example ¶
package main import ( "encoding/json" "fmt" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/protocol/websocket" ) func main() { conn := websocket.NewWebSocket("localhost:7512", nil) k, _ := kuzzle.NewKuzzle(conn, nil) type credentials struct { Username string `json:"username"` Password string `json:"password"` } myCredentials := credentials{"foo", "bar"} marsh, _ := json.Marshal(myCredentials) _, err := k.Auth.Login("local", marsh, nil) if err != nil { fmt.Println(err.Error()) return } k.UnsetJwt() fmt.Println(k.Jwt()) }
Output:
func (*Kuzzle) Volatile ¶
func (k *Kuzzle) Volatile() types.VolatileData
type KuzzleEventEmitter ¶
type KuzzleEventEmitter interface { AddListener(event int, channel chan<- interface{}) On(event int, channel chan<- interface{}) RemoveAllListeners(event int) RemoveListener(event int, channel chan<- interface{}) Once(event int, channel chan<- interface{}) ListenerCount(event int) int }
KuzzleEventEmitter Is an interface used by Kuzzle and Room instances to emit and listen to events (see Event Handling section).
type OfflineQueueLoader ¶
type OfflineQueueLoader interface {
Load() []*types.QueryObject
}