Overview
1. types/product_event
1.1 product_event.proto
Gravity's event relationship settings, under Protobuf format
enum Method {
INSERT = 0;
UPDATE = 1;
DELETE = 2;
TRUNCATE = 3;
}
message ProductEvent {
string eventName = 1;
string table = 2;
Method method = 3;
repeated string primaryKeys = 4;
bytes primaryKey = 5;
bytes data = 6;
}
| Item | Description |
|---|---|
| eventName | Defined event name |
| table | Selected Table |
| Method | Trigger condition, e.g., INSERT UPDATE DELETE TRUNCATE |
| primaryKeys | Primary Keys (repeated string) |
| primaryKey | Primary Key (bytes) |
| data | data in bytes (compton.Record) |
1.2 product_event.go
Provides Marshal\ Unmarshal method in relation to Product Event. Other than native Protobuf support, accessing its content require ProductEvent.Data.
See compton records for more information.
📝 Note:
compton/types/record/record.protois in Key-Value format
google.protobuf.Structis a JSON Object
message Record {
google.protobuf.Struct meta = 1;
Value payload = 2;
}
message Value {
DataType type = 1;
bytes value = 2;
MapValue map = 3;
ArrayValue array = 4;
google.protobuf.Timestamp timestamp = 5;
}
message MapValue {
repeated Field fields = 1;
}
message ArrayValue {
repeated Value elements = 1;
}
enum DataType {
BOOLEAN = 0;
BINARY = 1;
STRING = 2;
UINT64 = 3;
INT64 = 4;
FLOAT64 = 5;
ARRAY = 6;
MAP = 7;
NULL = 8;
TIME = 9;
}
2. product
2.1 product.go
This object performs CRUD actions on Product as well as registration of ProductClient
type ProductSetting struct {
Name string `json:"name"`
Description string `json:"desc"`
Enabled bool `json:"enabled"`
Rules map[string]*Rule `json:"rules"`
Schema map[string]interface{} `json:"schema"`
EnabledSnapshot bool `json:"enabledSnapshot"`
Snapshot *SnapshotSetting `json:"snapshot"`
Stream string `json:"stream"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type ProductClient struct {
options *Options
client *core.Client
configStore *config_store.ConfigStore
}
2.2 rule.go
You may assign rules to data products.
type Rule struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"desc"`
Event string `json:"event"`
Product string `json:"product"`
Method string `json:"method"`
PrimaryKey []string `json:"primaryKey"`
SchemaConfig map[string]interface{} `json:"schema,omitempty"`
HandlerConfig *HandlerConfig `json:"handler,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}