userv1

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_user_v1_command_proto protoreflect.FileDescriptor
View Source
var File_user_v1_domain_proto protoreflect.FileDescriptor
View Source
var File_user_v1_error_proto protoreflect.FileDescriptor
View Source
var File_user_v1_event_proto protoreflect.FileDescriptor
View Source
var File_user_v1_view_proto protoreflect.FileDescriptor

Functions

func DefaultIDGenerator

func DefaultIDGenerator(cmd *RegisterUser) string

Types

type Aggregate

type Aggregate interface {
	AggregateID() string
	Initialize(snapshot *Snapshot)
	CurrentSequence() int64
	IncrementSequence()
	UncommittedEvents() []*Event
	Snapshot() *Snapshot
	// contains filtered or unexported methods
}

type BaseAggregate

type BaseAggregate struct {
	ID       string
	Sequence int64
	State    *State
	// contains filtered or unexported fields
}

func (*BaseAggregate) AggregateID

func (b *BaseAggregate) AggregateID() string

func (*BaseAggregate) CurrentSequence

func (b *BaseAggregate) CurrentSequence() int64

func (*BaseAggregate) IncrementSequence

func (b *BaseAggregate) IncrementSequence()

func (*BaseAggregate) Initialize

func (b *BaseAggregate) Initialize(snapshot *Snapshot)

func (*BaseAggregate) Raise

func (b *BaseAggregate) Raise(eventData EventData)

func (*BaseAggregate) Snapshot

func (b *BaseAggregate) Snapshot() *Snapshot

func (*BaseAggregate) UncommittedEvents

func (b *BaseAggregate) UncommittedEvents() []*Event

type Codec

type Codec struct{}

func (*Codec) Aggregate

func (c *Codec) Aggregate() string

func (*Codec) Convert

func (c *Codec) Convert(record *publish.EventLog) (proto.Message, error)

type Command

type Command struct {
	Id   string        `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Data *Command_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Command) Descriptor deprecated

func (*Command) Descriptor() ([]byte, []int)

Deprecated: Use Command.ProtoReflect.Descriptor instead.

func (*Command) GetData

func (x *Command) GetData() *Command_Data

func (*Command) GetId

func (x *Command) GetId() string

func (*Command) ProtoMessage

func (*Command) ProtoMessage()

func (*Command) ProtoReflect

func (x *Command) ProtoReflect() protoreflect.Message

func (*Command) Reset

func (x *Command) Reset()

func (*Command) String

func (x *Command) String() string

type CommandData

type CommandData interface {
	CommandType() string
	// contains filtered or unexported methods
}

type CommandDispatcher

type CommandDispatcher struct {
	Client     client.Client
	GenerateID IDGeneratorFunc
}

func (*CommandDispatcher) Dispatch

func (c *CommandDispatcher) Dispatch(ctx context.Context, aggregateID string, commands ...CommandData) error

func (*CommandDispatcher) DispatchInitialCommand

func (c *CommandDispatcher) DispatchInitialCommand(ctx context.Context, cmd *RegisterUser) error

type CommandHandler

type CommandHandler struct {
	AggregateFactory func() UserAggregate
	EventStore       EventStore
	SnapshotRepo     SnapshotRepo
	SnapshotTrigger  func(*Snapshot) bool
	v1.UnimplementedAppCallbackServer
}

func (*CommandHandler) Handle

func (c *CommandHandler) Handle(ctx context.Context, cmd *Command) error

func (*CommandHandler) ListTopicSubscriptions

func (c *CommandHandler) ListTopicSubscriptions(ctx context.Context, _ *emptypb.Empty) (*v1.ListTopicSubscriptionsResponse, error)

func (*CommandHandler) OnTopicEvent

func (c *CommandHandler) OnTopicEvent(ctx context.Context, request *v1.TopicEventRequest) (*v1.TopicEventResponse, error)

func (*CommandHandler) Rehydrate

func (c *CommandHandler) Rehydrate(aggregate UserAggregate, events []*Event)

type Command_Data

type Command_Data struct {

	// Types that are assignable to Data:
	//	*Command_Data_Register
	//	*Command_Data_Deactivate
	Data isCommand_Data_Data `protobuf_oneof:"data"`
	// contains filtered or unexported fields
}

func (*Command_Data) Descriptor deprecated

func (*Command_Data) Descriptor() ([]byte, []int)

Deprecated: Use Command_Data.ProtoReflect.Descriptor instead.

func (*Command_Data) GetData

func (m *Command_Data) GetData() isCommand_Data_Data

func (*Command_Data) GetDeactivate

func (x *Command_Data) GetDeactivate() *DeactivateUser

func (*Command_Data) GetRegister

func (x *Command_Data) GetRegister() *RegisterUser

func (*Command_Data) ProtoMessage

func (*Command_Data) ProtoMessage()

func (*Command_Data) ProtoReflect

func (x *Command_Data) ProtoReflect() protoreflect.Message

func (*Command_Data) Reset

func (x *Command_Data) Reset()

func (*Command_Data) String

func (x *Command_Data) String() string

type Command_Data_Deactivate

type Command_Data_Deactivate struct {
	Deactivate *DeactivateUser `protobuf:"bytes,2,opt,name=deactivate,proto3,oneof"`
}

type Command_Data_Register

type Command_Data_Register struct {
	Register *RegisterUser `protobuf:"bytes,1,opt,name=register,proto3,oneof"`
}

type DeactivateUser

type DeactivateUser struct {
	Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason,omitempty"`
	// contains filtered or unexported fields
}

func (*DeactivateUser) CommandType

func (d *DeactivateUser) CommandType() string

func (*DeactivateUser) Descriptor deprecated

func (*DeactivateUser) Descriptor() ([]byte, []int)

Deprecated: Use DeactivateUser.ProtoReflect.Descriptor instead.

func (*DeactivateUser) GetReason

func (x *DeactivateUser) GetReason() string

func (*DeactivateUser) ProtoMessage

func (*DeactivateUser) ProtoMessage()

func (*DeactivateUser) ProtoReflect

func (x *DeactivateUser) ProtoReflect() protoreflect.Message

func (*DeactivateUser) Reset

func (x *DeactivateUser) Reset()

func (*DeactivateUser) String

func (x *DeactivateUser) String() string

type DynamoEventstore

type DynamoEventstore struct {
	Client *dynamodb.Client
	Table  string
}

func (*DynamoEventstore) Load

func (d *DynamoEventstore) Load(ctx context.Context, id string, seq int64) ([]*Event, error)

func (*DynamoEventstore) Save

func (d *DynamoEventstore) Save(ctx context.Context, events []*Event) error

type DynamoUserRepository

type DynamoUserRepository struct {
	Table  string
	Client *dynamodb.Client
}

func (*DynamoUserRepository) GetUser

func (d *DynamoUserRepository) GetUser(ctx context.Context, id string, age int64) (*User, error)

func (*DynamoUserRepository) ListScoresByCountry

func (d *DynamoUserRepository) ListScoresByCountry(ctx context.Context, country _type.CountryCode, score float64) ([]*User, error)

func (*DynamoUserRepository) ListUsers

func (d *DynamoUserRepository) ListUsers(ctx context.Context) ([]*User, error)

func (*DynamoUserRepository) ListUsersByCountry

func (d *DynamoUserRepository) ListUsersByCountry(ctx context.Context, country _type.CountryCode) ([]*User, error)

func (*DynamoUserRepository) PutUser

func (d *DynamoUserRepository) PutUser(ctx context.Context, user *User) error

type Error

type Error struct {
	Command *Command    `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	Data    *Error_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetCommand

func (x *Error) GetCommand() *Command

func (*Error) GetData

func (x *Error) GetData() *Error_Data

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type ErrorData

type ErrorData interface {
	Error() string
	ErrorType() string
	// contains filtered or unexported methods
}

type Error_Data

type Error_Data struct {

	// Types that are assignable to Data:
	//	*Error_Data_AlreadyRegistered
	//	*Error_Data_Unregistered
	Data isError_Data_Data `protobuf_oneof:"data"`
	// contains filtered or unexported fields
}

func (*Error_Data) Descriptor deprecated

func (*Error_Data) Descriptor() ([]byte, []int)

Deprecated: Use Error_Data.ProtoReflect.Descriptor instead.

func (*Error_Data) GetAlreadyRegistered

func (x *Error_Data) GetAlreadyRegistered() *UserAlreadyRegistered

func (*Error_Data) GetData

func (m *Error_Data) GetData() isError_Data_Data

func (*Error_Data) GetUnregistered

func (x *Error_Data) GetUnregistered() *UserUnregistered

func (*Error_Data) ProtoMessage

func (*Error_Data) ProtoMessage()

func (*Error_Data) ProtoReflect

func (x *Error_Data) ProtoReflect() protoreflect.Message

func (*Error_Data) Reset

func (x *Error_Data) Reset()

func (*Error_Data) String

func (x *Error_Data) String() string

type Error_Data_AlreadyRegistered

type Error_Data_AlreadyRegistered struct {
	AlreadyRegistered *UserAlreadyRegistered `protobuf:"bytes,1,opt,name=already_registered,json=alreadyRegistered,proto3,oneof"`
}

type Error_Data_Unregistered

type Error_Data_Unregistered struct {
	Unregistered *UserUnregistered `protobuf:"bytes,2,opt,name=unregistered,proto3,oneof"`
}

type Event

type Event struct {
	Id        string      `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Sequence  int64       `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"`
	Timestamp int64       `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Type      string      `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
	Data      *Event_Data `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Event) Descriptor deprecated

func (*Event) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetData

func (x *Event) GetData() *Event_Data

func (*Event) GetId

func (x *Event) GetId() string

func (*Event) GetSequence

func (x *Event) GetSequence() int64

func (*Event) GetTimestamp

func (x *Event) GetTimestamp() int64

func (*Event) GetType

func (x *Event) GetType() string

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Reset

func (x *Event) Reset()

func (*Event) String

func (x *Event) String() string

type EventData

type EventData interface {
	EventType() string
	// contains filtered or unexported methods
}

type EventHandler

type EventHandler interface {
	OnUserRegistered(ctx context.Context, aggregateID string, event *UserRegistered) error
	OnUserDeactivated(ctx context.Context, aggregateID string, event *UserDeactivated) error
}

type EventListener

type EventListener struct {
	Handler EventHandler
	v1.UnimplementedAppCallbackServer
}

func (*EventListener) Handle

func (e *EventListener) Handle(ctx context.Context, event *Event) error

func (*EventListener) ListTopicSubscriptions

func (e *EventListener) ListTopicSubscriptions(ctx context.Context, _ *emptypb.Empty) (*v1.ListTopicSubscriptionsResponse, error)

func (*EventListener) OnTopicEvent

func (e *EventListener) OnTopicEvent(ctx context.Context, request *v1.TopicEventRequest) (*v1.TopicEventResponse, error)

type EventStore

type EventStore interface {
	Load(ctx context.Context, id string, seq int64) ([]*Event, error)
	Save(ctx context.Context, events []*Event) error
}

type Event_Data

type Event_Data struct {

	// Types that are assignable to Data:
	//	*Event_Data_Registered
	//	*Event_Data_Deactivated
	Data isEvent_Data_Data `protobuf_oneof:"data"`
	// contains filtered or unexported fields
}

func (*Event_Data) Descriptor deprecated

func (*Event_Data) Descriptor() ([]byte, []int)

Deprecated: Use Event_Data.ProtoReflect.Descriptor instead.

func (*Event_Data) GetData

func (m *Event_Data) GetData() isEvent_Data_Data

func (*Event_Data) GetDeactivated

func (x *Event_Data) GetDeactivated() *UserDeactivated

func (*Event_Data) GetRegistered

func (x *Event_Data) GetRegistered() *UserRegistered

func (*Event_Data) ProtoMessage

func (*Event_Data) ProtoMessage()

func (*Event_Data) ProtoReflect

func (x *Event_Data) ProtoReflect() protoreflect.Message

func (*Event_Data) Reset

func (x *Event_Data) Reset()

func (*Event_Data) String

func (x *Event_Data) String() string

type Event_Data_Deactivated

type Event_Data_Deactivated struct {
	Deactivated *UserDeactivated `protobuf:"bytes,2,opt,name=deactivated,proto3,oneof"`
}

type Event_Data_Registered

type Event_Data_Registered struct {
	Registered *UserRegistered `protobuf:"bytes,1,opt,name=registered,proto3,oneof"`
}

type IDGeneratorFunc

type IDGeneratorFunc func(*RegisterUser) string

type RegisterUser

type RegisterUser struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Age   int64  `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
	Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	// contains filtered or unexported fields
}

func (*RegisterUser) CommandType

func (r *RegisterUser) CommandType() string

func (*RegisterUser) Descriptor deprecated

func (*RegisterUser) Descriptor() ([]byte, []int)

Deprecated: Use RegisterUser.ProtoReflect.Descriptor instead.

func (*RegisterUser) GetAge

func (x *RegisterUser) GetAge() int64

func (*RegisterUser) GetEmail

func (x *RegisterUser) GetEmail() string

func (*RegisterUser) GetName

func (x *RegisterUser) GetName() string

func (*RegisterUser) ProtoMessage

func (*RegisterUser) ProtoMessage()

func (*RegisterUser) ProtoReflect

func (x *RegisterUser) ProtoReflect() protoreflect.Message

func (*RegisterUser) Reset

func (x *RegisterUser) Reset()

func (*RegisterUser) String

func (x *RegisterUser) String() string

type Snapshot

type Snapshot struct {
	AggregateID string
	Sequence    int64
	State       *State
}

type SnapshotRepo

type SnapshotRepo interface {
	Persist(ctx context.Context, snapshot *Snapshot) error
	Retrieve(ctx context.Context, aggregateID string) (*Snapshot, error)
}

func NewInMemorySnapshotRepo

func NewInMemorySnapshotRepo() SnapshotRepo

type State

type State struct {
	Id       string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name     string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Email    string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	IsActive bool   `protobuf:"varint,4,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"`
	// contains filtered or unexported fields
}

func (*State) Descriptor deprecated

func (*State) Descriptor() ([]byte, []int)

Deprecated: Use State.ProtoReflect.Descriptor instead.

func (*State) GetEmail

func (x *State) GetEmail() string

func (*State) GetId

func (x *State) GetId() string

func (*State) GetIsActive

func (x *State) GetIsActive() bool

func (*State) GetName

func (x *State) GetName() string

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) ProtoReflect

func (x *State) ProtoReflect() protoreflect.Message

func (*State) Reset

func (x *State) Reset()

func (*State) String

func (x *State) String() string

type UnimplementedEventHandler

type UnimplementedEventHandler struct{}

func (UnimplementedEventHandler) OnUserDeactivated

func (UnimplementedEventHandler) OnUserDeactivated(ctx context.Context, aggregateID string, event *UserDeactivated) error

func (UnimplementedEventHandler) OnUserRegistered

func (UnimplementedEventHandler) OnUserRegistered(ctx context.Context, aggregateID string, event *UserRegistered) error

type User

type User struct {
	Id      string            `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Age     int64             `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
	Email   string            `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	Country _type.CountryCode `protobuf:"varint,4,opt,name=country,proto3,enum=type.CountryCode" json:"country,omitempty"`
	City    string            `protobuf:"bytes,5,opt,name=city,proto3" json:"city,omitempty"`
	Score   float64           `protobuf:"fixed64,6,opt,name=score,proto3" json:"score,omitempty"`
	// contains filtered or unexported fields
}

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GSI1SK

func (u *User) GSI1SK() types.AttributeValue

func (*User) GSI2SK

func (u *User) GSI2SK() types.AttributeValue

func (*User) GSI3PK

func (u *User) GSI3PK() types.AttributeValue

func (*User) GSI3SK

func (u *User) GSI3SK() types.AttributeValue

func (*User) GetAge

func (x *User) GetAge() int64

func (*User) GetCity

func (x *User) GetCity() string

func (*User) GetCountry

func (x *User) GetCountry() _type.CountryCode

func (*User) GetEmail

func (x *User) GetEmail() string

func (*User) GetId

func (x *User) GetId() string

func (*User) GetScore

func (x *User) GetScore() float64

func (*User) MarshalDynamoDBAttributeValue

func (u *User) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)

func (*User) PK

func (u *User) PK() types.AttributeValue

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) SK

func (u *User) SK() types.AttributeValue

func (*User) String

func (x *User) String() string

type UserAggregate

type UserAggregate interface {
	Aggregate
	HandleRegisterUser(cmd *RegisterUser) ErrorData
	HandleDeactivateUser(cmd *DeactivateUser) ErrorData
	OnUserRegistered(event *UserRegistered)
	OnUserDeactivated(event *UserDeactivated)
}

type UserAlreadyRegistered

type UserAlreadyRegistered struct {
	Id               string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	RegistrationTime int64  `protobuf:"varint,2,opt,name=registration_time,json=registrationTime,proto3" json:"registration_time,omitempty"`
	// contains filtered or unexported fields
}

func (*UserAlreadyRegistered) Descriptor deprecated

func (*UserAlreadyRegistered) Descriptor() ([]byte, []int)

Deprecated: Use UserAlreadyRegistered.ProtoReflect.Descriptor instead.

func (*UserAlreadyRegistered) Error

func (u *UserAlreadyRegistered) Error() string

func (*UserAlreadyRegistered) ErrorType

func (u *UserAlreadyRegistered) ErrorType() string

func (*UserAlreadyRegistered) GetId

func (x *UserAlreadyRegistered) GetId() string

func (*UserAlreadyRegistered) GetRegistrationTime

func (x *UserAlreadyRegistered) GetRegistrationTime() int64

func (*UserAlreadyRegistered) ProtoMessage

func (*UserAlreadyRegistered) ProtoMessage()

func (*UserAlreadyRegistered) ProtoReflect

func (x *UserAlreadyRegistered) ProtoReflect() protoreflect.Message

func (*UserAlreadyRegistered) Reset

func (x *UserAlreadyRegistered) Reset()

func (*UserAlreadyRegistered) String

func (x *UserAlreadyRegistered) String() string

type UserDeactivated

type UserDeactivated struct {
	// contains filtered or unexported fields
}

func (*UserDeactivated) Descriptor deprecated

func (*UserDeactivated) Descriptor() ([]byte, []int)

Deprecated: Use UserDeactivated.ProtoReflect.Descriptor instead.

func (*UserDeactivated) EventType

func (u *UserDeactivated) EventType() string

func (*UserDeactivated) ProtoMessage

func (*UserDeactivated) ProtoMessage()

func (*UserDeactivated) ProtoReflect

func (x *UserDeactivated) ProtoReflect() protoreflect.Message

func (*UserDeactivated) Reset

func (x *UserDeactivated) Reset()

func (*UserDeactivated) String

func (x *UserDeactivated) String() string

type UserRegistered

type UserRegistered struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	// contains filtered or unexported fields
}

func (*UserRegistered) Descriptor deprecated

func (*UserRegistered) Descriptor() ([]byte, []int)

Deprecated: Use UserRegistered.ProtoReflect.Descriptor instead.

func (*UserRegistered) EventType

func (u *UserRegistered) EventType() string

func (*UserRegistered) GetEmail

func (x *UserRegistered) GetEmail() string

func (*UserRegistered) GetName

func (x *UserRegistered) GetName() string

func (*UserRegistered) ProtoMessage

func (*UserRegistered) ProtoMessage()

func (*UserRegistered) ProtoReflect

func (x *UserRegistered) ProtoReflect() protoreflect.Message

func (*UserRegistered) Reset

func (x *UserRegistered) Reset()

func (*UserRegistered) String

func (x *UserRegistered) String() string

type UserRepository

type UserRepository interface {
	PutUser(ctx context.Context, user *User) error
	GetUser(ctx context.Context, id string, age int64) (*User, error)
	ListUsers(ctx context.Context) ([]*User, error)
	ListUsersByCountry(ctx context.Context, country _type.CountryCode) ([]*User, error)
	ListScoresByCountry(ctx context.Context, country _type.CountryCode, score float64) ([]*User, error)
}

type UserUnregistered

type UserUnregistered struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*UserUnregistered) Descriptor deprecated

func (*UserUnregistered) Descriptor() ([]byte, []int)

Deprecated: Use UserUnregistered.ProtoReflect.Descriptor instead.

func (*UserUnregistered) Error

func (u *UserUnregistered) Error() string

func (*UserUnregistered) ErrorType

func (u *UserUnregistered) ErrorType() string

func (*UserUnregistered) GetId

func (x *UserUnregistered) GetId() string

func (*UserUnregistered) ProtoMessage

func (*UserUnregistered) ProtoMessage()

func (*UserUnregistered) ProtoReflect

func (x *UserUnregistered) ProtoReflect() protoreflect.Message

func (*UserUnregistered) Reset

func (x *UserUnregistered) Reset()

func (*UserUnregistered) String

func (x *UserUnregistered) String() string

Jump to

Keyboard shortcuts

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