feat: scaffold agentmon services and k8s deploy
Adds Go microservices (ingest-gateway, event-processor, query-api, web-ui), NATS+Postgres wiring, initial schema/init job, ingress manifests for LAN+tailnet, and a multi-arch image build script.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type InsertEvent struct {
|
||||
EventID string
|
||||
TS time.Time
|
||||
Type string
|
||||
|
||||
SessionID sql.NullString
|
||||
RunID sql.NullString
|
||||
TraceID sql.NullString
|
||||
SpanID sql.NullString
|
||||
ParentSpanID sql.NullString
|
||||
|
||||
SourceFramework sql.NullString
|
||||
ClientID sql.NullString
|
||||
Payload any
|
||||
}
|
||||
|
||||
func (d *DB) InsertEvent(ctx context.Context, e InsertEvent) error {
|
||||
payload, err := json.Marshal(e.Payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = d.sql.ExecContext(ctx, `
|
||||
insert into events (
|
||||
event_id, ts, type, session_id, run_id, trace_id, span_id, parent_span_id,
|
||||
source_framework, client_id, payload
|
||||
) values (
|
||||
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11
|
||||
)
|
||||
on conflict (event_id) do nothing
|
||||
`,
|
||||
e.EventID,
|
||||
e.TS,
|
||||
e.Type,
|
||||
e.SessionID,
|
||||
e.RunID,
|
||||
e.TraceID,
|
||||
e.SpanID,
|
||||
e.ParentSpanID,
|
||||
e.SourceFramework,
|
||||
e.ClientID,
|
||||
payload,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
var ErrMissingField = errors.New("missing required field")
|
||||
Reference in New Issue
Block a user