You've already forked agentic-coding-workflow
feat(acp): sqlc queries (agent_kinds + sessions + events) + generated code
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: events.sql
|
||||
|
||||
package acpsqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const insertEvent = `-- name: InsertEvent :one
|
||||
INSERT INTO acp_events (
|
||||
session_id, direction, rpc_kind, method, payload, payload_size, truncated
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING id, session_id, direction, rpc_kind, method, payload,
|
||||
payload_size, truncated, created_at
|
||||
`
|
||||
|
||||
type InsertEventParams struct {
|
||||
SessionID pgtype.UUID `json:"session_id"`
|
||||
Direction string `json:"direction"`
|
||||
RpcKind string `json:"rpc_kind"`
|
||||
Method *string `json:"method"`
|
||||
Payload []byte `json:"payload"`
|
||||
PayloadSize int32 `json:"payload_size"`
|
||||
Truncated bool `json:"truncated"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) (AcpEvent, error) {
|
||||
row := q.db.QueryRow(ctx, insertEvent,
|
||||
arg.SessionID,
|
||||
arg.Direction,
|
||||
arg.RpcKind,
|
||||
arg.Method,
|
||||
arg.Payload,
|
||||
arg.PayloadSize,
|
||||
arg.Truncated,
|
||||
)
|
||||
var i AcpEvent
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.SessionID,
|
||||
&i.Direction,
|
||||
&i.RpcKind,
|
||||
&i.Method,
|
||||
&i.Payload,
|
||||
&i.PayloadSize,
|
||||
&i.Truncated,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listEventsSince = `-- name: ListEventsSince :many
|
||||
SELECT id, session_id, direction, rpc_kind, method, payload,
|
||||
payload_size, truncated, created_at
|
||||
FROM acp_events
|
||||
WHERE session_id = $1 AND id > $2
|
||||
ORDER BY id ASC
|
||||
LIMIT $3
|
||||
`
|
||||
|
||||
type ListEventsSinceParams struct {
|
||||
SessionID pgtype.UUID `json:"session_id"`
|
||||
ID int64 `json:"id"`
|
||||
Limit int32 `json:"limit"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListEventsSince(ctx context.Context, arg ListEventsSinceParams) ([]AcpEvent, error) {
|
||||
rows, err := q.db.Query(ctx, listEventsSince, arg.SessionID, arg.ID, arg.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AcpEvent
|
||||
for rows.Next() {
|
||||
var i AcpEvent
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.SessionID,
|
||||
&i.Direction,
|
||||
&i.RpcKind,
|
||||
&i.Method,
|
||||
&i.Payload,
|
||||
&i.PayloadSize,
|
||||
&i.Truncated,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const purgeEventsBefore = `-- name: PurgeEventsBefore :execrows
|
||||
DELETE FROM acp_events WHERE created_at < $1
|
||||
`
|
||||
|
||||
func (q *Queries) PurgeEventsBefore(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, purgeEventsBefore, createdAt)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user