kuzzle

package
v0.0.0-...-084a6c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package kuzzle provides a Kuzzle Entry point and main struct for the entire SDK

Index

Examples

Constants

View Source
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 NewKuzzle

func NewKuzzle(c protocol.Protocol, options types.Options) (*Kuzzle, error)

NewKuzzle is the Kuzzle constructor

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) AutoQueue

func (k *Kuzzle) AutoQueue() bool

AutoQueue returns the Kuzzle socket AutoQueue field value

func (*Kuzzle) AutoReconnect

func (k *Kuzzle) AutoReconnect() bool

AutoReconnect returns the Kuzzle socket AutoReconnect field value

func (*Kuzzle) AutoReplay

func (k *Kuzzle) AutoReplay() bool

AutoReplay returns the Kuzzle socket AutoReplay field value

func (*Kuzzle) AutoResubscribe

func (k *Kuzzle) AutoResubscribe() bool

AutoResubscribe returns the Kuzzle socket AutoQueue field value

func (*Kuzzle) Connect

func (k *Kuzzle) Connect() error

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

func (k *Kuzzle) Disconnect() error

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) EmitEvent

func (k *Kuzzle) EmitEvent(e int, arg interface{})

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

func (k *Kuzzle) Jwt() string

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 (k *Kuzzle) ListenerCount(event int) int

func (*Kuzzle) OfflineQueue

func (k *Kuzzle) OfflineQueue() []*types.QueryObject

OfflineQueue returns the Kuzzle socket OfflineQueue field value

Example
package main

import ()

func main() {
	//todo
}
Output:

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) Once

func (k *Kuzzle) Once(event int, channel chan<- json.RawMessage)

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

func (k *Kuzzle) QueueMaxSize() int

QueueMaxSize returns the Kuzzle socket QueueMaxSize field value

func (*Kuzzle) QueueTTL

func (k *Kuzzle) QueueTTL() time.Duration

QueueTTL returns the Kuzzle socket QueueTTL field value

func (*Kuzzle) ReconnectionDelay

func (k *Kuzzle) ReconnectionDelay() time.Duration

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

func (k *Kuzzle) RemoveAllListeners(event int)

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

func (k *Kuzzle) ReplayInterval() time.Duration

ReplayInterval returns the Kuzzle socket ReplayInterval field value

func (*Kuzzle) SetAutoQueue

func (k *Kuzzle) SetAutoQueue(v bool)

SetAutoQueue sets the Kuzzle socket AutoQueue field with the given value

func (*Kuzzle) SetAutoReplay

func (k *Kuzzle) SetAutoReplay(v bool)

SetAutoReplay sets the Kuzzle socket AutoReplay field with the given value

func (*Kuzzle) SetJwt

func (k *Kuzzle) SetJwt(token string)

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

func (k *Kuzzle) SetQueueMaxSize(v int)

SetQueueMaxSize sets the Kuzzle socket QueueMaxSize field with the given value

func (*Kuzzle) SetQueueTTL

func (k *Kuzzle) SetQueueTTL(v time.Duration)

SetQueueTTL sets the Kuzzle socket QueueTTL field with the given value

func (*Kuzzle) SetReplayInterval

func (k *Kuzzle) SetReplayInterval(v time.Duration)

SetReplayInterval sets the Kuzzle socket ReplayInterval field with the given value

func (*Kuzzle) SetVolatile

func (k *Kuzzle) SetVolatile(v types.VolatileData)

func (*Kuzzle) SslConnection

func (k *Kuzzle) SslConnection() bool

SslConnection returns the Kuzzle socket SslConnection field value

func (*Kuzzle) StartQueuing

func (k *Kuzzle) StartQueuing()

StartQueuing start the requests queuing.

func (*Kuzzle) StopQueuing

func (k *Kuzzle) StopQueuing()

StopQueuing stop the requests queuing.

func (*Kuzzle) UnregisterSub

func (k *Kuzzle) UnregisterSub(roomId string)

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
}

type QueueFilter

type QueueFilter func([]byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL