Antodis

Seshat Go SDK

TR | EN

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 struct fields (Go)

SensorValue

FindOptions setters

Notes

Machines Listing

mopt := c.Machines.FindOpts()
mopt.SetTag("production")
machines, total, err := c.Machines.Find(ctx, mopt)

Returns

Machine struct fields (Go)

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.

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

IoTDataRecord

IoTDataMetadata
IoTDataChangeMeta

IoTQueryOptions Setters

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})