SDK
SDK Golang v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Publish #

Sends a real-time <message> to Kuzzle. The <message> will be dispatched to all clients with subscriptions matching the <index>, the <collection> and the <message> content.

The <index> and <collection> are indicative and serve only to distinguish the rooms. They are not required to exist in the database

Note: real-time messages are not persisted in the database.

Arguments #

Copied to clipboard!
func (r *Realtime) Publish(
  index string,
  collection string,
  message json.RawMessage,
  options types.QueryOptions
) error

Arguments Type Description
index
string
Index name
collection
string
Collection name
message
json.RawMessage
Message to send
options
types.QueryOptions
Query options

options #

Additional query options

Option Type
(default)
Description
queuable
bool

(true)
Make this request queuable or not

Return #

Return an error is something was wrong.

Usage #

Copied to clipboard!
message := json.RawMessage(`{ "realtime": "rule the web" }`)
err := kuzzle.Realtime.Publish("i-dont-exist", "i-database", message, nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println("Success")
}