Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: command_replays.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const completeCommandReplay = `-- name: CompleteCommandReplay :execrows
UPDATE command_replays
SET resource_id=$1, response_status=$2::int,
response_body=$3::bytea, state='completed'
WHERE scope=$4::text
AND operation=$5::text
AND key=$6::text
AND state='reserved'
`
type CompleteCommandReplayParams struct {
ResourceID pgtype.Text `json:"resource_id"`
ResponseStatus int32 `json:"response_status"`
ResponseBody []byte `json:"response_body"`
Scope string `json:"scope"`
Operation string `json:"operation"`
Key string `json:"key"`
}
// Only reserved work completes.
func (q *Queries) CompleteCommandReplay(ctx context.Context, arg CompleteCommandReplayParams) (int64, error) {
result, err := q.db.Exec(ctx, completeCommandReplay,
arg.ResourceID,
arg.ResponseStatus,
arg.ResponseBody,
arg.Scope,
arg.Operation,
arg.Key,
)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const createCommandReplay = `-- name: CreateCommandReplay :exec
INSERT INTO command_replays (
scope, operation, key, request_hash, state, resource_id, response_status, response_body,
invocation_id, credential_id
) VALUES (
$1, $2, $3, $4, $5,
$6, $7, $8,
$9, $10
)
`
type CreateCommandReplayParams struct {
Scope string `json:"scope"`
Operation string `json:"operation"`
Key string `json:"key"`
RequestHash []byte `json:"request_hash"`
State string `json:"state"`
ResourceID pgtype.Text `json:"resource_id"`
ResponseStatus pgtype.Int4 `json:"response_status"`
ResponseBody []byte `json:"response_body"`
InvocationID pgtype.Text `json:"invocation_id"`
CredentialID pgtype.Text `json:"credential_id"`
}
func (q *Queries) CreateCommandReplay(ctx context.Context, arg CreateCommandReplayParams) error {
_, err := q.db.Exec(ctx, createCommandReplay,
arg.Scope,
arg.Operation,
arg.Key,
arg.RequestHash,
arg.State,
arg.ResourceID,
arg.ResponseStatus,
arg.ResponseBody,
arg.InvocationID,
arg.CredentialID,
)
return err
}
const deleteReservedCommandReplay = `-- name: DeleteReservedCommandReplay :exec
DELETE FROM command_replays
WHERE scope=$1::text
AND operation=$2::text
AND key=$3::text
AND state='reserved'
`
type DeleteReservedCommandReplayParams struct {
Scope string `json:"scope"`
Operation string `json:"operation"`
Key string `json:"key"`
}
func (q *Queries) DeleteReservedCommandReplay(ctx context.Context, arg DeleteReservedCommandReplayParams) error {
_, err := q.db.Exec(ctx, deleteReservedCommandReplay, arg.Scope, arg.Operation, arg.Key)
return err
}
const getCommandReplay = `-- name: GetCommandReplay :one
SELECT request_hash, resource_id, response_status, response_body, state, invocation_id
FROM command_replays
WHERE scope=$1::text
AND operation=$2::text
AND key=$3::text
`
type GetCommandReplayParams struct {
Scope string `json:"scope"`
Operation string `json:"operation"`
Key string `json:"key"`
}
type GetCommandReplayRow struct {
RequestHash []byte `json:"request_hash"`
ResourceID pgtype.Text `json:"resource_id"`
ResponseStatus pgtype.Int4 `json:"response_status"`
ResponseBody []byte `json:"response_body"`
State string `json:"state"`
InvocationID pgtype.Text `json:"invocation_id"`
}
func (q *Queries) GetCommandReplay(ctx context.Context, arg GetCommandReplayParams) (GetCommandReplayRow, error) {
row := q.db.QueryRow(ctx, getCommandReplay, arg.Scope, arg.Operation, arg.Key)
var i GetCommandReplayRow
err := row.Scan(
&i.RequestHash,
&i.ResourceID,
&i.ResponseStatus,
&i.ResponseBody,
&i.State,
&i.InvocationID,
)
return i, err
}
const getCommandReplayForUpdate = `-- name: GetCommandReplayForUpdate :one
SELECT request_hash, resource_id, response_status, response_body, state, invocation_id
FROM command_replays
WHERE scope=$1::text
AND operation=$2::text
AND key=$3::text
FOR UPDATE
`
type GetCommandReplayForUpdateParams struct {
Scope string `json:"scope"`
Operation string `json:"operation"`
Key string `json:"key"`
}
type GetCommandReplayForUpdateRow struct {
RequestHash []byte `json:"request_hash"`
ResourceID pgtype.Text `json:"resource_id"`
ResponseStatus pgtype.Int4 `json:"response_status"`
ResponseBody []byte `json:"response_body"`
State string `json:"state"`
InvocationID pgtype.Text `json:"invocation_id"`
}
func (q *Queries) GetCommandReplayForUpdate(ctx context.Context, arg GetCommandReplayForUpdateParams) (GetCommandReplayForUpdateRow, error) {
row := q.db.QueryRow(ctx, getCommandReplayForUpdate, arg.Scope, arg.Operation, arg.Key)
var i GetCommandReplayForUpdateRow
err := row.Scan(
&i.RequestHash,
&i.ResourceID,
&i.ResponseStatus,
&i.ResponseBody,
&i.State,
&i.InvocationID,
)
return i, err
}