Documentation
¶
Index ¶
- Constants
- Variables
- func NewRepository(store protosource.Store, serializer protosource.Serializer, ...) *protosource.Repository
- type Builder
- type Create
- func (m *Create) CommandName() string
- func (*Create) Descriptor() ([]byte, []int)deprecated
- func (m *Create) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
- func (x *Create) GetActor() string
- func (x *Create) GetBody() string
- func (x *Create) GetId() string
- func (*Create) ProtoMessage()
- func (x *Create) ProtoReflect() protoreflect.Message
- func (m *Create) ProtoValidate() error
- func (x *Create) Reset()
- func (x *Create) String() string
- func (m *Create) ValidateVersion(version int64) error
- type Created
- func (*Created) Descriptor() ([]byte, []int)deprecated
- func (m *Created) EventName() string
- func (x *Created) GetActor() string
- func (x *Created) GetAt() int64
- func (x *Created) GetBody() string
- func (x *Created) GetId() string
- func (x *Created) GetVersion() int64
- func (*Created) ProtoMessage()
- func (x *Created) ProtoReflect() protoreflect.Message
- func (x *Created) Reset()
- func (x *Created) String() string
- type HTTPClient
- func (c *HTTPClient) Create(ctx context.Context, id string, body string) (*responsev1.CommandResponse, error)
- func (c *HTTPClient) Get(ctx context.Context, id string) (*Test, error)
- func (c *HTTPClient) History(ctx context.Context, id string) (*historyv1.History, error)
- func (c *HTTPClient) Load(ctx context.Context, id string) (*Test, error)
- func (c *HTTPClient) Lock(ctx context.Context, id string) (*responsev1.CommandResponse, error)
- func (c *HTTPClient) Unlock(ctx context.Context, id string) (*responsev1.CommandResponse, error)
- func (c *HTTPClient) Update(ctx context.Context, id string, body string) (*responsev1.CommandResponse, error)
- type Handler
- func (h *Handler) HandleCreate(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleGet(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleGetMaterialized(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleHistory(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleLock(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleUnlock(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) HandleUpdate(ctx context.Context, request protosource.Request) protosource.Response
- func (h *Handler) RegisterRoutes(router *protosource.Router)
- type Lock
- func (m *Lock) Authorize(aggregate protosource.Aggregate) error
- func (m *Lock) CommandName() string
- func (*Lock) Descriptor() ([]byte, []int)deprecated
- func (m *Lock) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
- func (x *Lock) GetActor() string
- func (x *Lock) GetId() string
- func (*Lock) ProtoMessage()
- func (x *Lock) ProtoReflect() protoreflect.Message
- func (m *Lock) ProtoValidate() error
- func (x *Lock) Reset()
- func (x *Lock) String() string
- func (m *Lock) ValidateVersion(version int64) error
- type Locked
- func (*Locked) Descriptor() ([]byte, []int)deprecated
- func (m *Locked) EventName() string
- func (x *Locked) GetActor() string
- func (x *Locked) GetAt() int64
- func (x *Locked) GetId() string
- func (x *Locked) GetVersion() int64
- func (*Locked) ProtoMessage()
- func (x *Locked) ProtoReflect() protoreflect.Message
- func (x *Locked) Reset()
- func (x *Locked) String() string
- type Repo
- type Snapshot
- func (*Snapshot) Descriptor() ([]byte, []int)deprecated
- func (m *Snapshot) EventName() string
- func (x *Snapshot) GetActor() string
- func (x *Snapshot) GetAt() int64
- func (x *Snapshot) GetId() string
- func (x *Snapshot) GetSnapshot() *Test
- func (x *Snapshot) GetVersion() int64
- func (*Snapshot) ProtoMessage()
- func (x *Snapshot) ProtoReflect() protoreflect.Message
- func (x *Snapshot) Reset()
- func (x *Snapshot) String() string
- type State
- type Test
- func (*Test) Descriptor() ([]byte, []int)deprecated
- func (aggregate *Test) EventTTLSeconds() int64
- func (m *Test) GSI1PK() string
- func (m *Test) GSI1SK() string
- func (m *Test) GSI2PK() string
- func (m *Test) GSI2SK() string
- func (m *Test) GSI3PK() string
- func (m *Test) GSI3SK() string
- func (m *Test) GSI4PK() string
- func (m *Test) GSI4SK() string
- func (m *Test) GSI5PK() string
- func (m *Test) GSI5SK() string
- func (m *Test) GSI6PK() string
- func (m *Test) GSI6SK() string
- func (m *Test) GSI7PK() string
- func (m *Test) GSI7SK() string
- func (m *Test) GSI8PK() string
- func (m *Test) GSI8SK() string
- func (m *Test) GSI9PK() string
- func (m *Test) GSI9SK() string
- func (m *Test) GSI10PK() string
- func (m *Test) GSI10SK() string
- func (m *Test) GSI11PK() string
- func (m *Test) GSI11SK() string
- func (m *Test) GSI12PK() string
- func (m *Test) GSI12SK() string
- func (m *Test) GSI13PK() string
- func (m *Test) GSI13SK() string
- func (m *Test) GSI14PK() string
- func (m *Test) GSI14SK() string
- func (m *Test) GSI15PK() string
- func (m *Test) GSI15SK() string
- func (m *Test) GSI16PK() string
- func (m *Test) GSI16SK() string
- func (m *Test) GSI17PK() string
- func (m *Test) GSI17SK() string
- func (m *Test) GSI18PK() string
- func (m *Test) GSI18SK() string
- func (m *Test) GSI19PK() string
- func (m *Test) GSI19SK() string
- func (m *Test) GSI20PK() string
- func (m *Test) GSI20SK() string
- func (x *Test) GetBody() string
- func (x *Test) GetCreateAt() int64
- func (x *Test) GetCreateBy() string
- func (x *Test) GetId() string
- func (x *Test) GetModifyAt() int64
- func (x *Test) GetModifyBy() string
- func (x *Test) GetState() State
- func (x *Test) GetVersion() int64
- func (m *Test) Hydrate(body []byte) error
- func (aggregate *Test) On(event protosource.Event) error
- func (m *Test) PK() string
- func (*Test) ProtoMessage()
- func (x *Test) ProtoReflect() protoreflect.Message
- func (x *Test) Reset()
- func (aggregate *Test) RestoreSnapshot(snapshot *Snapshot)
- func (m *Test) SK() string
- func (aggregate *Test) Snapshot(version int64) protosource.Event
- func (aggregate *Test) SnapshotInterval() int32
- func (x *Test) String() string
- type TestClient
- func (c *TestClient) AddTest(ctx context.Context, d *Test, opts ...opaquedata.Option) error
- func (c *TestClient) DeleteTest(ctx context.Context, id string) error
- func (c *TestClient) GetTest(ctx context.Context, id string) (*Test, error)
- func (c *TestClient) UpdateTest(ctx context.Context, d *Test, opts ...opaquedata.Option) error
- type TestList
- type Unlock
- func (m *Unlock) Authorize(aggregate protosource.Aggregate) error
- func (m *Unlock) CommandName() string
- func (*Unlock) Descriptor() ([]byte, []int)deprecated
- func (m *Unlock) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
- func (x *Unlock) GetActor() string
- func (x *Unlock) GetId() string
- func (*Unlock) ProtoMessage()
- func (x *Unlock) ProtoReflect() protoreflect.Message
- func (m *Unlock) ProtoValidate() error
- func (x *Unlock) Reset()
- func (x *Unlock) String() string
- func (m *Unlock) ValidateVersion(version int64) error
- type Unlocked
- func (*Unlocked) Descriptor() ([]byte, []int)deprecated
- func (m *Unlocked) EventName() string
- func (x *Unlocked) GetActor() string
- func (x *Unlocked) GetAt() int64
- func (x *Unlocked) GetId() string
- func (x *Unlocked) GetVersion() int64
- func (*Unlocked) ProtoMessage()
- func (x *Unlocked) ProtoReflect() protoreflect.Message
- func (x *Unlocked) Reset()
- func (x *Unlocked) String() string
- type Update
- func (m *Update) Authorize(aggregate protosource.Aggregate) error
- func (m *Update) CommandName() string
- func (*Update) Descriptor() ([]byte, []int)deprecated
- func (m *Update) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
- func (x *Update) GetActor() string
- func (x *Update) GetBody() string
- func (x *Update) GetId() string
- func (*Update) ProtoMessage()
- func (x *Update) ProtoReflect() protoreflect.Message
- func (m *Update) ProtoValidate() error
- func (x *Update) Reset()
- func (x *Update) String() string
- func (m *Update) ValidateVersion(version int64) error
- type Updated
- func (*Updated) Descriptor() ([]byte, []int)deprecated
- func (m *Updated) EventName() string
- func (x *Updated) GetActor() string
- func (x *Updated) GetAt() int64
- func (x *Updated) GetBody() string
- func (x *Updated) GetId() string
- func (x *Updated) GetVersion() int64
- func (*Updated) ProtoMessage()
- func (x *Updated) ProtoReflect() protoreflect.Message
- func (x *Updated) Reset()
- func (x *Updated) String() string
Constants ¶
const EventTTLDuration int64 = 86400
EventTTLDuration is the event TTL from the proto annotation.
const SnapshotEveryNEvents int32 = 3
SnapshotEveryNEvents is the snapshot interval from the proto annotation.
Variables ¶
var ( State_name = map[int32]string{ 0: "STATE_UNSPECIFIED", 1: "STATE_UNLOCKED", 2: "STATE_LOCKED", } State_value = map[string]int32{ "STATE_UNSPECIFIED": 0, "STATE_UNLOCKED": 1, "STATE_LOCKED": 2, } )
Enum value maps for State.
var File_example_app_test_v1_test_v1_proto protoreflect.FileDescriptor
Functions ¶
func NewRepository ¶
func NewRepository(store protosource.Store, serializer protosource.Serializer, opts ...protosource.Option) *protosource.Repository
NewRepository creates a new protosource.Repository for the Test aggregate.
Types ¶
type Builder ¶
type Builder struct {
Events []protosource.Event
// contains filtered or unexported fields
}
func NewBuilder ¶
type Create ¶
type Create struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"`
Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
// contains filtered or unexported fields
}
Create is the command that is used to create a test. Emits Created (domain fields) then Unlocked (initial state).
func (*Create) CommandName ¶
func (*Create) Descriptor
deprecated
func (*Create) EmitEvents ¶
func (m *Create) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
func (*Create) ProtoMessage ¶
func (*Create) ProtoMessage()
func (*Create) ProtoReflect ¶
func (x *Create) ProtoReflect() protoreflect.Message
func (*Create) ProtoValidate ¶
func (*Create) ValidateVersion ¶
type Created ¶
type Created struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
At int64 `protobuf:"varint,3,opt,name=at,proto3" json:"at,omitempty"`
Actor string `protobuf:"bytes,4,opt,name=actor,proto3" json:"actor,omitempty"`
Body string `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`
// contains filtered or unexported fields
}
Created is the event emitted when we create a test.
func (*Created) Descriptor
deprecated
func (*Created) GetVersion ¶
func (*Created) ProtoMessage ¶
func (*Created) ProtoMessage()
func (*Created) ProtoReflect ¶
func (x *Created) ProtoReflect() protoreflect.Message
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a typed HTTP client for the Test aggregate.
func NewHTTPClient ¶
func NewHTTPClient(c httpclient.Doer) *HTTPClient
NewHTTPClient creates a new Test HTTP client. Accepts httpclient.Doer for testability — use *httpclient.Client in production and a mock in tests.
func (*HTTPClient) Create ¶
func (c *HTTPClient) Create(ctx context.Context, id string, body string) (*responsev1.CommandResponse, error)
Create sends the Create command.
func (*HTTPClient) Lock ¶
func (c *HTTPClient) Lock(ctx context.Context, id string) (*responsev1.CommandResponse, error)
Lock sends the Lock command.
func (*HTTPClient) Unlock ¶
func (c *HTTPClient) Unlock(ctx context.Context, id string) (*responsev1.CommandResponse, error)
Unlock sends the Unlock command.
func (*HTTPClient) Update ¶
func (c *HTTPClient) Update(ctx context.Context, id string, body string) (*responsev1.CommandResponse, error)
Update sends the Update command.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides request handler functions for the Test aggregate.
func NewHandler ¶
func NewHandler(repo Repo, client *TestClient) *Handler
NewHandler creates a new Handler instance with the given repository and client.
func (*Handler) HandleCreate ¶
func (h *Handler) HandleCreate(ctx context.Context, request protosource.Request) protosource.Response
HandleCreate processes a Create command.
func (*Handler) HandleGet ¶
func (h *Handler) HandleGet(ctx context.Context, request protosource.Request) protosource.Response
HandleGet retrieves the current state of a Test aggregate.
func (*Handler) HandleGetMaterialized ¶
func (h *Handler) HandleGetMaterialized(ctx context.Context, request protosource.Request) protosource.Response
HandleGetMaterialized retrieves the Test aggregate from the materialized store.
func (*Handler) HandleHistory ¶
func (h *Handler) HandleHistory(ctx context.Context, request protosource.Request) protosource.Response
HandleHistory retrieves the full event history for a Test aggregate.
func (*Handler) HandleLock ¶
func (h *Handler) HandleLock(ctx context.Context, request protosource.Request) protosource.Response
HandleLock processes a Lock command.
func (*Handler) HandleUnlock ¶
func (h *Handler) HandleUnlock(ctx context.Context, request protosource.Request) protosource.Response
HandleUnlock processes a Unlock command.
func (*Handler) HandleUpdate ¶
func (h *Handler) HandleUpdate(ctx context.Context, request protosource.Request) protosource.Response
HandleUpdate processes a Update command.
func (*Handler) RegisterRoutes ¶
func (h *Handler) RegisterRoutes(router *protosource.Router)
RegisterRoutes registers all handler routes on the given router.
type Lock ¶
type Lock struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"`
// contains filtered or unexported fields
}
Lock is the command that locks the aggregate.
func (*Lock) CommandName ¶
func (*Lock) Descriptor
deprecated
func (*Lock) EmitEvents ¶
func (m *Lock) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
func (*Lock) ProtoMessage ¶
func (*Lock) ProtoMessage()
func (*Lock) ProtoReflect ¶
func (x *Lock) ProtoReflect() protoreflect.Message
func (*Lock) ProtoValidate ¶
func (*Lock) ValidateVersion ¶
type Locked ¶
type Locked struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
At int64 `protobuf:"varint,3,opt,name=at,proto3" json:"at,omitempty"`
Actor string `protobuf:"bytes,4,opt,name=actor,proto3" json:"actor,omitempty"`
// contains filtered or unexported fields
}
Locked is the event emitted when the aggregate is locked.
func (*Locked) Descriptor
deprecated
func (*Locked) GetVersion ¶
func (*Locked) ProtoMessage ¶
func (*Locked) ProtoMessage()
func (*Locked) ProtoReflect ¶
func (x *Locked) ProtoReflect() protoreflect.Message
type Repo ¶
type Repo interface {
protosource.Repo
}
Repo is a package-specific interface for dependency injection. It embeds protosource.Repo so that *protosource.Repository satisfies it, while giving each aggregate package a distinct type for Wire.
type Snapshot ¶
type Snapshot struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
At int64 `protobuf:"varint,3,opt,name=at,proto3" json:"at,omitempty"`
Actor string `protobuf:"bytes,4,opt,name=actor,proto3" json:"actor,omitempty"`
Snapshot *Test `protobuf:"bytes,5,opt,name=snapshot,proto3" json:"snapshot,omitempty"`
// contains filtered or unexported fields
}
Snapshot is the snapshot of the aggregate
func (*Snapshot) Descriptor
deprecated
func (*Snapshot) GetSnapshot ¶
func (*Snapshot) GetVersion ¶
func (*Snapshot) ProtoMessage ¶
func (*Snapshot) ProtoMessage()
func (*Snapshot) ProtoReflect ¶
func (x *Snapshot) ProtoReflect() protoreflect.Message
type State ¶
type State int32
func (State) Descriptor ¶
func (State) Descriptor() protoreflect.EnumDescriptor
func (State) EnumDescriptor
deprecated
func (State) Number ¶
func (x State) Number() protoreflect.EnumNumber
func (State) Type ¶
func (State) Type() protoreflect.EnumType
type Test ¶
type Test struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
CreateAt int64 `protobuf:"varint,3,opt,name=create_at,json=createAt,proto3" json:"create_at,omitempty"`
CreateBy string `protobuf:"bytes,4,opt,name=create_by,json=createBy,proto3" json:"create_by,omitempty"`
ModifyAt int64 `protobuf:"varint,5,opt,name=modify_at,json=modifyAt,proto3" json:"modify_at,omitempty"`
ModifyBy string `protobuf:"bytes,6,opt,name=modify_by,json=modifyBy,proto3" json:"modify_by,omitempty"`
Body string `protobuf:"bytes,7,opt,name=body,proto3" json:"body,omitempty"`
State State `protobuf:"varint,8,opt,name=state,proto3,enum=example.app.test.v1.State" json:"state,omitempty"`
// contains filtered or unexported fields
}
Test is the aggregate.
It must be defined first in the proto, its name must match the first part of the package.
func (*Test) Descriptor
deprecated
func (*Test) EventTTLSeconds ¶
func (*Test) GetCreateAt ¶
func (*Test) GetCreateBy ¶
func (*Test) GetModifyAt ¶
func (*Test) GetModifyBy ¶
func (*Test) GetVersion ¶
func (*Test) On ¶
func (aggregate *Test) On(event protosource.Event) error
On applies an event to the aggregate, rebuilding its state. This method is called during Repository.Load to reconstruct from stored events, and during test scenarios. Events represent facts — never reject based on business rules.
func (*Test) ProtoMessage ¶
func (*Test) ProtoMessage()
func (*Test) ProtoReflect ¶
func (x *Test) ProtoReflect() protoreflect.Message
func (*Test) RestoreSnapshot ¶
func (*Test) SnapshotInterval ¶
type TestClient ¶
type TestClient struct {
// contains filtered or unexported fields
}
func NewTestClient ¶
func NewTestClient(store opaquedata.OpaqueStore) *TestClient
func (*TestClient) AddTest ¶
func (c *TestClient) AddTest(ctx context.Context, d *Test, opts ...opaquedata.Option) error
func (*TestClient) DeleteTest ¶
func (c *TestClient) DeleteTest(ctx context.Context, id string) error
func (*TestClient) UpdateTest ¶
func (c *TestClient) UpdateTest(ctx context.Context, d *Test, opts ...opaquedata.Option) error
type TestList ¶
type TestList struct {
Items []*Test `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
// contains filtered or unexported fields
}
func (*TestList) Descriptor
deprecated
func (*TestList) ProtoMessage ¶
func (*TestList) ProtoMessage()
func (*TestList) ProtoReflect ¶
func (x *TestList) ProtoReflect() protoreflect.Message
type Unlock ¶
type Unlock struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"`
// contains filtered or unexported fields
}
Unlock is the command that unlocks the aggregate.
func (*Unlock) CommandName ¶
func (*Unlock) Descriptor
deprecated
func (*Unlock) EmitEvents ¶
func (m *Unlock) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
func (*Unlock) ProtoMessage ¶
func (*Unlock) ProtoMessage()
func (*Unlock) ProtoReflect ¶
func (x *Unlock) ProtoReflect() protoreflect.Message
func (*Unlock) ProtoValidate ¶
func (*Unlock) ValidateVersion ¶
type Unlocked ¶
type Unlocked struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
At int64 `protobuf:"varint,3,opt,name=at,proto3" json:"at,omitempty"`
Actor string `protobuf:"bytes,4,opt,name=actor,proto3" json:"actor,omitempty"`
// contains filtered or unexported fields
}
Unlocked is the event emitted when the aggregate is unlocked.
func (*Unlocked) Descriptor
deprecated
func (*Unlocked) GetVersion ¶
func (*Unlocked) ProtoMessage ¶
func (*Unlocked) ProtoMessage()
func (*Unlocked) ProtoReflect ¶
func (x *Unlocked) ProtoReflect() protoreflect.Message
type Update ¶
type Update struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"`
Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
// contains filtered or unexported fields
}
Update is the command that is used to update a test.
func (*Update) CommandName ¶
func (*Update) Descriptor
deprecated
func (*Update) EmitEvents ¶
func (m *Update) EmitEvents(aggregate protosource.Aggregate) []protosource.Event
func (*Update) ProtoMessage ¶
func (*Update) ProtoMessage()
func (*Update) ProtoReflect ¶
func (x *Update) ProtoReflect() protoreflect.Message
func (*Update) ProtoValidate ¶
func (*Update) ValidateVersion ¶
type Updated ¶
type Updated struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
At int64 `protobuf:"varint,3,opt,name=at,proto3" json:"at,omitempty"`
Actor string `protobuf:"bytes,4,opt,name=actor,proto3" json:"actor,omitempty"`
Body string `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`
// contains filtered or unexported fields
}
Updated is the event emitted when we update a test.
func (*Updated) Descriptor
deprecated
func (*Updated) GetVersion ¶
func (*Updated) ProtoMessage ¶
func (*Updated) ProtoMessage()
func (*Updated) ProtoReflect ¶
func (x *Updated) ProtoReflect() protoreflect.Message
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Code generated by protoc-gen-protosource.
|
Code generated by protoc-gen-protosource. |