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 #
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 #
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")
}
Edit this page on Github(opens new window)