Files
archie/internal/infrastructure/staterpc/client.go
T
sam cc5789eb5f feat(scheduling): schedules and runs in the State Store with grid timing and run history
Schedules leave the schedules control-plane resource for State Store tables
behind a ScheduleService contract. A run is claimed per schedule slot, missed
slots fire once, the next run stays on the schedule's grid, cron is read in the
schedule-settings time zone, and failed runs are recorded and advance. Three
failures in a row raise a schedule.failing alert. A fired run records a
schedule-fired capture. Run history is pruned by age and count.

Removes the chat and spawn-task runners, the dangerous-payload guard and the
old schedules settings page.
2026-10-26 00:49:24 +11:00

115 lines
4.8 KiB
Go

package staterpc
import (
"context"
"google.golang.org/grpc"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
pb "github.com/samcharles93/archie-core/internal/contracts/state/v1"
"github.com/samcharles93/archie-core/internal/domain/identity"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/domain/storepkg"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
)
// Client is the single remote adapter over the State Store services,
// asserted against whichever narrow Go interfaces its caller needs -- exactly
// as gatewayrpc.Client asserts both messaging.ChatContract and
// messaging.SessionStore.
type Client struct {
packages pb.PackageServiceClient
taskGrant pb.TaskGrantServiceClient
harnessSecret pb.HarnessSecretServiceClient
account pb.AccountServiceClient
identity pb.IdentityServiceClient
task pb.TaskServiceClient
execution pb.ExecutionServiceClient
review pb.ReviewServiceClient
taskEvent pb.TaskEventServiceClient
stats pb.StatsServiceClient
taskLog pb.TaskLogServiceClient
status pb.StatusServiceClient
capture pb.CaptureServiceClient
mapping pb.MappingServiceClient
eventType pb.EventTypeServiceClient
binding pb.BindingServiceClient
dispatch pb.DispatchServiceClient
source pb.SourceServiceClient
access pb.AccessServiceClient
org pb.OrgServiceClient
alert pb.AlertServiceClient
audit pb.AuditServiceClient
schedule pb.ScheduleServiceClient
controlPlane controlpb.ControlPlaneServiceClient
}
// NewClient wraps conn's generated clients. Close is a no-op: the store
// service owns its own DB lifecycle.
func NewClient(conn grpc.ClientConnInterface) *Client {
return &Client{
packages: pb.NewPackageServiceClient(conn),
taskGrant: pb.NewTaskGrantServiceClient(conn),
harnessSecret: pb.NewHarnessSecretServiceClient(conn),
account: pb.NewAccountServiceClient(conn),
identity: pb.NewIdentityServiceClient(conn),
task: pb.NewTaskServiceClient(conn),
execution: pb.NewExecutionServiceClient(conn),
review: pb.NewReviewServiceClient(conn),
taskEvent: pb.NewTaskEventServiceClient(conn),
stats: pb.NewStatsServiceClient(conn),
taskLog: pb.NewTaskLogServiceClient(conn),
status: pb.NewStatusServiceClient(conn),
capture: pb.NewCaptureServiceClient(conn),
mapping: pb.NewMappingServiceClient(conn),
eventType: pb.NewEventTypeServiceClient(conn),
binding: pb.NewBindingServiceClient(conn),
dispatch: pb.NewDispatchServiceClient(conn),
source: pb.NewSourceServiceClient(conn),
access: pb.NewAccessServiceClient(conn),
org: pb.NewOrgServiceClient(conn),
alert: pb.NewAlertServiceClient(conn),
audit: pb.NewAuditServiceClient(conn),
schedule: pb.NewScheduleServiceClient(conn),
controlPlane: controlpb.NewControlPlaneServiceClient(conn),
}
}
// ControlPlane returns the generic control-plane RPC client on the same authenticated connection.
func (c *Client) ControlPlane() controlpb.ControlPlaneServiceClient { return c.controlPlane }
// Close is a no-op; the remote store service owns its own DB lifecycle.
func (c *Client) Close() error { return nil }
var (
_ storecontract.HarnessSecretStore = (*Client)(nil)
_ task.Store = (*Client)(nil)
_ task.Caller = (*Client)(nil)
_ storecontract.TaskStore = (*Client)(nil)
_ storecontract.TaskLogStore = (*Client)(nil)
_ storecontract.CaptureStore = (*Client)(nil)
_ storecontract.MappingStore = (*Client)(nil)
_ storecontract.BindingStore = (*Client)(nil)
_ storecontract.SourceStore = (*Client)(nil)
_ storecontract.BindingDispatcher = (*Client)(nil)
_ storecontract.MappingMatchRecorder = (*Client)(nil)
_ storecontract.BindingTaskCreator = (*Client)(nil)
_ storecontract.PlaybookDispatcher = (*Client)(nil)
_ storecontract.ConfigSnapshotStore = (*Client)(nil)
_ storecontract.ChannelStatusStore = (*Client)(nil)
_ storecontract.ApplyStatusStore = (*Client)(nil)
_ storecontract.PresenceStore = (*Client)(nil)
_ storecontract.CaptureRefusalStore = (*Client)(nil)
_ storecontract.ExecutionCanceller = (*Client)(nil)
_ identity.Repository = (*Client)(nil)
_ storepkg.Installations = (*Client)(nil)
_ identity.PersonalTokens = (*Client)(nil)
)
// Lifecycle
// Tasks returns the most recently updated tasks.
func (c *Client) Tasks(ctx context.Context, limit int) ([]task.Task, error) {
return c.TasksPage(ctx, storecontract.TaskPage{Limit: limit})
}