client

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: MIT Imports: 9 Imported by: 0

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

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) Append

func (c *Client) Append(ctx context.Context, e Event) (string, error)

Append records a single event and returns its server-assigned id.

func (*Client) AppendBatch

func (c *Client) AppendBatch(ctx context.Context, events []Event) (int, error)

AppendBatch streams a batch of events and returns how many were persisted.

func (*Client) Query

func (c *Client) Query(ctx context.Context, f Filter) ([]Event, error)

Query returns events matching the filter, newest first.

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.

type Filter

type Filter struct {
	ActorID      string
	ResourceType string
	ResourceID   string
	Action       string
	From         *time.Time
	To           *time.Time
	Limit        int
}

Filter narrows a Query. Zero-value fields are not constrained.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL