diff --git a/db/client.go b/db/client.go index 4edf17e..2fd7613 100644 --- a/db/client.go +++ b/db/client.go @@ -78,18 +78,7 @@ func (c *ClickhouseClient) BulkInsertRequests(ctx context.Context, requests []*R } for _, r := range requests { - err = batch.Append( - r.UUID.String(), - r.QueenID, - r.AntID.String(), - r.RemoteID.String(), - r.AgentVersion, - r.Protocols, - r.StartedAt, - r.Type, - r.KeyID, - r.MultiAddresses, - ) + err = batch.AppendStruct(r) if err != nil { return fmt.Errorf("append request to batch: %w", err) } diff --git a/db/models.go b/db/models.go index 513b2fc..1b71a62 100644 --- a/db/models.go +++ b/db/models.go @@ -9,14 +9,14 @@ import ( ) type Request struct { - UUID uuid.UUID - QueenID string - AntID peer.ID - RemoteID peer.ID - Type pb.Message_MessageType - AgentVersion string - Protocols []string - StartedAt time.Time - KeyID string - MultiAddresses []string + UUID uuid.UUID `ch:"id"` + QueenID string `ch:"queen_id"` + AntID peer.ID `ch:"ant_multihash"` + RemoteID peer.ID `ch:"remote_multihash"` + RequestType pb.Message_MessageType `ch:"request_type"` + AgentVersion string `ch:"agent_version"` + Protocols []string `ch:"protocols"` + StartedAt time.Time `ch:"started_at"` + KeyID string `ch:"key_multihash"` + MultiAddresses []string `ch:"multi_addresses"` } diff --git a/queen.go b/queen.go index 78dd832..6c38cf8 100644 --- a/queen.go +++ b/queen.go @@ -223,7 +223,7 @@ func (q *Queen) consumeAntsEvents(ctx context.Context) { QueenID: q.id, AntID: evt.Self, RemoteID: evt.Remote, - Type: evt.Type, + RequestType: evt.Type, AgentVersion: evt.AgentVersion, Protocols: protocolStrs, StartedAt: evt.Timestamp,