Skip to content

Commit

Permalink
use append struct to be independent on column order
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis-tra committed Dec 16, 2024
1 parent 7ad4fe4 commit 226c011
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
13 changes: 1 addition & 12 deletions db/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
20 changes: 10 additions & 10 deletions db/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion queen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 226c011

Please sign in to comment.