|
| 1 | +import {Tabs} from 'nextra/components' |
| 2 | + |
| 3 | +# Notifications |
| 4 | + |
| 5 | +Oxia allows applications to get a feed of all the changes happening in a given namespace. This is |
| 6 | +similar to a database change-data-capture (CDC). |
| 7 | + |
| 8 | +Once a notification object is created, a client is guaranteed to receive notification of |
| 9 | +all the changes happening in Oxia after that point, even in the presence of an arbitrary number |
| 10 | +of failures. |
| 11 | + |
| 12 | +## Subscribing to notifications |
| 13 | + |
| 14 | + <Tabs items={['Go', 'Java', 'CLI']}> |
| 15 | + <Tabs.Tab> |
| 16 | + ```go |
| 17 | + notifications, err := client.GetNotifications() |
| 18 | + defer notifications.Close() |
| 19 | + |
| 20 | + for notification := range notifications.Ch() { |
| 21 | + fmt.Println(notification) |
| 22 | + } |
| 23 | + ``` |
| 24 | + </Tabs.Tab> |
| 25 | + <Tabs.Tab> |
| 26 | + ```java |
| 27 | + client.notifications(notification -> { |
| 28 | + System.out.println("Got notification: " + notification); |
| 29 | + }); |
| 30 | + ``` |
| 31 | + </Tabs.Tab> |
| 32 | + <Tabs.Tab> |
| 33 | + ```shell |
| 34 | + oxia client notifications |
| 35 | + ``` |
| 36 | + </Tabs.Tab> |
| 37 | + </Tabs> |
| 38 | + |
| 39 | +### Notification event types |
| 40 | + |
| 41 | +| Name | Description | |
| 42 | +|------------------------|----------------------------------------| |
| 43 | +| `KeyCreated` | A record that didn't exist was created | |
| 44 | +| `KeyModified` | An existing record was modified | |
| 45 | +| `KeyDeleted` | A record was deleted | |
| 46 | +| `KeyRangeRangeDeleted` | A range of keys was deleted | |
| 47 | + |
| 48 | +Notification event fields: |
| 49 | + |
| 50 | +| Name | Type | Description | |
| 51 | +|---------------|--------------------|--------------------------------------------------------------------------------------------------------------| |
| 52 | +| `Type` | `NotificationType` | The type of the modification | |
| 53 | +| `Key` | `string` | The Key of the record to which the notification is referring | |
| 54 | +| `VersionId` | `int64` | The current VersionId of the record, or -1 for a KeyDeleted event | |
| 55 | +| `KeyRangeEnd` | `string` | In case of a KeyRangeRangeDeleted notification, this would represent the end (excluded) of the range of keys | |
| 56 | + |
| 57 | +## Disabling notifications |
| 58 | + |
| 59 | +Notifications are enabled by default on namespaces. Since there is some overhead for preparing the notifications |
| 60 | +feed, if an application doesn't need this feature it can be disabled. |
| 61 | + |
| 62 | +In the coordinator `config.yaml`, set `notificationsEnabled=false` on the specific namespace configuration. |
0 commit comments