Documentation
¶
Overview ¶
Package client is the consumer-facing SDK for Hallmark's gRPC surface. Other forge services dial Hallmark once and emit audit events through it; returned gRPC status codes are mapped to kit apierrors.
Index ¶
- type Client
- func (c *Client) Append(ctx context.Context, e Event) (string, error)
- func (c *Client) AppendBatch(ctx context.Context, events []Event) (int, error)
- func (c *Client) Query(ctx context.Context, f Filter) ([]Event, error)
- func (c *Client) Subscribe(ctx context.Context, f Filter, replayFrom *time.Time, replayLimit int, ...) error
- type Event
- type Filter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps Hallmark's gRPC surface with kit error mapping.
func New ¶
func New(conn grpc.ClientConnInterface) *Client
New builds a client over an established connection to Hallmark.
func NewFromServiceClient ¶
func NewFromServiceClient(c hallmarkv1.HallmarkServiceClient) *Client
NewFromServiceClient is the seam tests use to inject a fake gRPC client.
func (*Client) AppendBatch ¶
AppendBatch streams a batch of events and returns how many were persisted.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, f Filter, replayFrom *time.Time, replayLimit int, fn func(Event) error) error
Subscribe opens a live tail. When replayFrom is set, matching history from that time is replayed (oldest first) before the live events. It invokes fn for each event until fn returns an error, the context is cancelled, or the server closes the stream; a clean server close returns nil.
type Event ¶
type Event struct {
ID string
Timestamp time.Time
RealmID string
ActorID string
ActorType string
ResourceType string
ResourceID string
Action string
Summary string
Changes map[string]any
Metadata map[string]any
IP string
RequestID string
}
Event is the SDK-facing shape of an audit event to emit. ID and Timestamp are server-assigned when left zero.