HandleNotification processes incoming notifications and updates Typesense collections based on the table and data. It ensures the required fields exist and upserts the data into Typesense.
(ctx context.Context, table string, data map[string]interface{})
| 229 | // HandleNotification processes incoming notifications and updates Typesense collections based on the table and data. |
| 230 | // It ensures the required fields exist and upserts the data into Typesense. |
| 231 | func (t *TypesenseClient) HandleNotification(ctx context.Context, table string, data map[string]interface{}) error { |
| 232 | config, ok := collectionConfigs[table] |
| 233 | if !ok { |
| 234 | return fmt.Errorf("unknown collection: %s", table) |
| 235 | } |
| 236 | |
| 237 | // Process and normalize the data |
| 238 | if err := t.processMetadata(data); err != nil { |
| 239 | return err |
| 240 | } |
| 241 | t.convertLargeNumbers(config, data) |
| 242 | t.ensureSchemaFields(config, data) |
| 243 | t.normalizeTimeFields(config, data) |
| 244 | |
| 245 | // Upsert the document |
| 246 | return t.upsertDocument(ctx, table, data) |
| 247 | } |
| 248 | |
| 249 | // HandleBatchNotification processes a batch of items and indexes them in dependency order. |
| 250 | // It first indexes all dependencies (e.g., balances), then indexes the primary item (e.g., transaction). |
no test coverage detected