Go SDK
Typed services & unified option patterns (FindOptions, LiveOptions, IoTQueryOptions).
Install
go get git.antodis.com/seshat/sdk
Module
Loading module info…
Initialize Client
c := sdk.NewAntodisSdk(apiKey, secret,
sdk.WithHost("localhost"), // seshat host
)
Sensors: Find & Pagination
opt := c.Sensors.FindOpts()
opt.SetName("temp")
opt.SetTag("critical")
opt.SetAll(true)
err := c.Sensors.FindEachPage(ctx, opt, func(items []sdk.Sensor, total, page, limit int) bool {
// handle items
return true
})
Functions overview: Find performs a single page fetch returning sensors and total count. FindEachPage iterates sequential pages invoking your handler with items + pagination until all pages consumed or handler returns false. FindHandler lets you inspect pagination metadata only (total/page/limit) across pages when All is true, useful for progress reporting before calling FindEachPage. All filters combine with AND semantics; zero values are omitted from query string. Errors halt iteration immediately.
Returns
Find / FindEachPage callbacks return sensor models and pagination info.
[]Sensor: list of sensorstotal int: total count across all pagespage int,limit int: current page metadata
Sensor struct fields (Go)
ID(string)Name(string)Key(string)Company(string)Machine(string)Collector(string)Tags([]string)IsDeleted(bool)CreationDate(int64)DataType(int)LatestValue(SensorValue)LatestChange(SensorValue)Generative(bool)SendOnlyChange(bool)
SensorValue
Date(string, ISO)Type(int)Value(any)
FindOptions setters
opt.SetName(string): Case-insensitive substring filter on sensor/machine names.opt.SetKey(string): Exact key filter (unique identifier when applicable).opt.SetTag(string): Comma-separated tag list. Matches items having any of the provided tags (e.g."prod,critical").opt.SetMachine(string)/opt.SetCollector(string): Filter by owning machine/collector id or name (aliases; services choose one).opt.SetLimit(int): Page size for pagination helpers. If not set, backend default applies. Ignored whenopt.SetAll(true).opt.SetPage(int): 1-based page index for manual pagination. Ignored by auto handlers or whenAlltrue.opt.SetAll(bool): Enable auto-pagination across all pages; overrides limit/page.
Notes
- Combine setters arbitrarily; resulting filters use AND semantics.
- Server may cap page size; larger SetLimit values are reduced silently.
- Same setters pattern also applies to Machines service (collector vs machine naming).
Machines Listing
mopt := c.Machines.FindOpts()
mopt.SetTag("production")
machines, total, err := c.Machines.Find(ctx, mopt)
Returns
[]Machine: list of machinestotal int: total count
Machine struct fields (Go)
ID(string)Collector(string)Company(string)Name(string)Key(string)Tags([]string)CreatedBy(string)CreationDate(int64)SendMqttDirect(bool)
Live
err = c.Sensors.Live(func(sensorId string, data any, dataType int) {
fmt.Println(sensorId, data, dataType)
})
Data Types (t → Go type)
In the Live callback, t is the type id and v is the corresponding Go type below.
1→int2→uint3→int84→uint85→int166→uint167→int328→uint329→int6410→uint6411→float6412→time.Time13→string14→[]int3215→[]byte16→bool17→map[string]any18→[]map[string]any19→any(raw JSON)22→string
Live functions: Live (default context) and LiveContext build on LiveWith. They attempt a streaming subscription first; if the stream disconnects or is unavailable, they fall back to periodic polling of latest sensor values. When no sensor list is provided, the client refreshes the sensor ID list at a slower interval (60s) to capture newly added sensors. Callback exceptions are recovered silently to avoid breaking the loop. Cancel the provided context to stop streaming.
IoT Data (Typed)
q := sdk.IotData.QueryOptions()
q.SetSensorIDs("sensor123")
q.SetPerPage(50)
q.SortByDateDesc()
resp, _ := c.Sensors.IotData(ctx, q)
for _, item := range resp.Items {
_ = item.Value
}
IoT endpoints: IotData returns raw time-series value records per sensor; IotDataChanges returns change-focused intervals (with before/after metadata) when the backend tracks transitions. Both accept IoTQueryOptions built via setters: pagination (Page, PerPage), temporal bounds (StartDate, EndDate), numeric range (Min/Max), exact value match (Value), and ordering (SortBy/SortOrder). Empty fields are omitted so you can layer filters incrementally.
Returns
IoTDataResponse
Items []IoTDataRecordOk boolPage int,PerPage int,Total intSensorIDs []string
IoTDataRecord
Timestamp string(ISO)Value anyMetadata *IoTDataMetadata(optional)
IoTDataMetadata
CompanyID(string)Machine(string)Sensor(string)Change(bool)BeforeChangeData(*IoTDataChangeMeta)ChangeData(*IoTDataChangeMeta)TogetherTrigger(string)TogetherValues(map[string]any)
IoTDataChangeMeta
Start(string)End(string)DurationMS(int64)StartValue(any)EndValue(any)IncValue(float64)DecValue(float64)StartID(string)
IoTQueryOptions Setters
SetSensorIDs(ids ...string)/SetSensorIDsCSV(csv)/AddSensorID(id): Sensör ID listesi (virgülle ayrılmış).SetStartDate(string)/SetEndDate(string): Başlangıç/bitiş zaman damgası (RFC3339 veya unix epoch).SetValue(string): Tam değer eşleşmesi (string/numeric/bool serileşmiş).SetMin(float64)/SetMax(float64): Sayısal aralık filtreleri.SetPage(int)/SetPerPage(int): Sayfalama parametreleri (>=1).SetSortBy("date"|"value")/SetSortOrder("asc"|"desc"): Sıralama kontrolü.SortByDateAsc(),SortByDateDesc(),SortByValueAsc(),SortByValueDesc(): Kısayol sıralama.
Connections Write
Each sensor is bound to a connection. The endpoints a sensor reads from or writes to are called connections. For example, a connection can be an MQTT client or a PostgreSQL database connection. To write data to an MQTT connection, use the Connections service together with the MQTT driver's parameters.
// Advanced write (single bool item with topic parameter)
var r bool = true
vd, _ := json.Marshal(r)
items := []*proto.WriteItem{
{Value: vd, AnyValue: &anypb.Any{Value: vd}, Type: 16, Parameters: []*proto.KeyValue{
{Key: "topic", Value: []byte("67333c8d615f8c6cd6f07c38/67333c8d615f8c6cd6f07c39")},
}},
}
err := c.Connections.Write(ctx, "mqtt://0.0.0.0:8888", items)
Error handling
// Single call with error check
sensors, total, err := c.Sensors.Find(ctx, c.Sensors.FindOpts())
if err != nil { /* log + return */ }
// Iteration with early stop on error inside handler
_ = c.Sensors.FindEachPage(ctx, opt, func(items []sdk.Sensor, total, page, limit int) bool {
// process
return true
})
// Live with context timeout & retry on transient errors
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
if err := c.Sensors.LiveWith(ctx, sdk.LiveOptions{Interval: time.Second}, cb); err != nil {
// if transient, backoff and retry
}
Events Trigger
resp, err := c.Events.Trigger(ctx, "rebuild-cache", map[string]any{"fast": true})