Documentation ¶
Index ¶
- type Realtime
- func (r *Realtime) Count(roomID string, options types.QueryOptions) (int, error)
- func (r *Realtime) Publish(index string, collection string, body json.RawMessage, ...) error
- func (r *Realtime) Subscribe(index, collection string, filters json.RawMessage, ...) (*types.SubscribeResult, error)
- func (r *Realtime) Unsubscribe(roomID string, options types.QueryOptions) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Realtime ¶
type Realtime struct {
// contains filtered or unexported fields
}
Realtime controller
func NewRealtime ¶
NewRealtime instanciates a new realtime controller
func (*Realtime) Publish ¶
func (r *Realtime) Publish(index string, collection string, body json.RawMessage, options types.QueryOptions) error
Publish sends a real-time message to Kuzzle
func (*Realtime) Subscribe ¶
func (r *Realtime) Subscribe(index, collection string, filters json.RawMessage, cb chan<- types.NotificationResult, options types.RoomOptions) (*types.SubscribeResult, error)
Subscribe permits to join a previously created subscription
Example ¶
package main import ( "encoding/json" "github.com/kuzzleio/sdk-go/internal" "github.com/kuzzleio/sdk-go/kuzzle" "github.com/kuzzleio/sdk-go/realtime" "github.com/kuzzleio/sdk-go/state" "github.com/kuzzleio/sdk-go/types" ) func main() { c := &internal.MockedConnection{ MockSend: func(query []byte, options types.QueryOptions) *types.KuzzleResponse { roomRaw := []byte(`{"requestId": "rqid", "channel": "foo", "roomId": "42"}`) return &types.KuzzleResponse{Result: roomRaw} }, } k, _ := kuzzle.NewKuzzle(c, nil) nr := realtime.NewRealtime(k) c.SetState(state.Connected) notifChan := make(chan<- types.NotificationResult) nr.Subscribe("collection", "index", json.RawMessage(""), notifChan, nil) }
Output:
func (*Realtime) Unsubscribe ¶
func (r *Realtime) Unsubscribe(roomID string, options types.QueryOptions) error
Unsubscribe instructs Kuzzle to detach you from its subscribers for the given room
Click to show internal directories.
Click to hide internal directories.