manager

package
v0.0.0-...-d8c5dba Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnrollmentManager

type EnrollmentManager struct {
	PersonManager       PersonManagerInterface
	EnrollmentDao       dao.EnrollmentDaoInterface
	EnrollmentPublisher publisher.EnrollmentPublisher
	SeatManager         SeatManagerInterface
}

func NewEnrollmentManager

func NewEnrollmentManager(
	personManager PersonManagerInterface,
	enrollmentDao dao.EnrollmentDaoInterface,
	enrollmentPublisher publisher.EnrollmentPublisher,
	seatManager SeatManagerInterface,
) *EnrollmentManager

func (*EnrollmentManager) CancelEnrollmentAndPublish

func (em *EnrollmentManager) CancelEnrollmentAndPublish(ctx context.Context, evt fun.EnrollmentCancelledEvtV1) common.HttpError

CancelEnrollmentAndPublish persists CANCELLED status and emits cancellation event when status changes.

func (*EnrollmentManager) EnrollCmd

EnrollCmd coordinates seat allocation by delegating to SeatManager.

func (*EnrollmentManager) EnrollPerson

func (em *EnrollmentManager) EnrollPerson(ctx context.Context, personID string, grade int) (fun.Enrollment, common.HttpError)

func (*EnrollmentManager) GetEnrollment

func (em *EnrollmentManager) GetEnrollment(ctx context.Context, personID string) (fun.Enrollment, common.HttpError)

func (*EnrollmentManager) OnEnrollmentCancelledEvt

func (em *EnrollmentManager) OnEnrollmentCancelledEvt(ctx context.Context, evt fun.EnrollmentCancelledEvtV1) common.HttpError

OnEnrollmentCancelledEvt persists CANCELLED status without publishing.

func (*EnrollmentManager) OnEnrollmentConfirmedEvt

func (em *EnrollmentManager) OnEnrollmentConfirmedEvt(ctx context.Context, evt fun.EnrollmentConfirmedEvtV1) common.HttpError

OnEnrollmentConfirmedEvt persists CONFIRMED status without publishing.

func (*EnrollmentManager) OnSeatReservedEvt

func (em *EnrollmentManager) OnSeatReservedEvt(ctx context.Context, enrollment fun.Enrollment) common.HttpError

OnSeatReservedEvt persists CONFIRMED status and publishes confirmation when status changes.

func (*EnrollmentManager) UpdateToWaitlisted

func (em *EnrollmentManager) UpdateToWaitlisted(ctx context.Context, enrollment fun.Enrollment) common.HttpError

UpdateToWaitlisted persists WAITLISTED status without publishing.

type EnrollmentManagerInterface

type EnrollmentManagerInterface interface {
	EnrollPerson(ctx context.Context, personID string, grade int) (fun.Enrollment, common.HttpError)
	GetEnrollment(ctx context.Context, personID string) (fun.Enrollment, common.HttpError)
	EnrollCmd(ctx context.Context, cmd fun.EnrollCmdV1) common.HttpError
	OnSeatReservedEvt(ctx context.Context, enrollment fun.Enrollment) common.HttpError
	UpdateToWaitlisted(ctx context.Context, enrollment fun.Enrollment) common.HttpError
	CancelEnrollmentAndPublish(ctx context.Context, evt fun.EnrollmentCancelledEvtV1) common.HttpError
	OnEnrollmentConfirmedEvt(ctx context.Context, evt fun.EnrollmentConfirmedEvtV1) common.HttpError
	OnEnrollmentCancelledEvt(ctx context.Context, evt fun.EnrollmentCancelledEvtV1) common.HttpError
}

EnrollmentManagerInterface orchestrates enrollment flows and delegates seat allocation.

Architecture rules enforced here:

  • Flow is always Handler -> Manager -> Publisher. Handlers never publish directly.
  • Managers only talk to their own publisher; cross-domain messages use Manager-to-Manager calls.
  • EnrollmentManager responsibilities:
  • EnrollPerson persists an initiated enrollment and publishes EnrollCmd (C1).
  • EnrollCmd delegates seat allocation to SeatManager, which publishes AllocateSeat (C2).
  • OnSeatReservedEvt persists status and emits EnrollmentConfirmedEvt.
  • CancelEnrollmentAndPublish persists status and emits EnrollmentCancelledEvt for origin-side cancellations.
  • OnEnrollmentConfirmedEvt and OnEnrollmentCancelledEvt are idempotent sinks that persist status without publishing.
  • SeatManager publishes only seat-related commands/events and never touches enrollment publishers.

TODO: #C Rename Person usage to Student once the domain model is updated.

type PersonManager

type PersonManager struct {
	Dao    dao.PersonDaoInterface
	Tracer trace.Tracer
}

func NewPersonManager

func NewPersonManager(dao dao.PersonDaoInterface, tracer trace.Tracer) *PersonManager

func (*PersonManager) CreatePerson

func (p *PersonManager) CreatePerson(c context.Context, request fun.PersonRequest) (person fun.Person, err common.HttpError)

CreatePerson creates a new person in the PersonManager.

It takes two parameters: - c: a context.Context object representing the current context. - person: Person object representing the person to be created.

It returns two values: - id: a string representing the ID of the newly created person. - err: an error representing any error that occurred during the creation process.

func (*PersonManager) DeletePerson

func (p *PersonManager) DeletePerson(c context.Context, id string) (err common.HttpError)

func (*PersonManager) GetPerson

func (p *PersonManager) GetPerson(c context.Context, id string) (person fun.Person, err common.HttpError)

func (*PersonManager) ListPersonAudit

func (p *PersonManager) ListPersonAudit(c context.Context, id string) (response []fun.PersonAudit, err common.HttpError)

func (*PersonManager) ListPersons

func (p *PersonManager) ListPersons(c context.Context, personQuery fun.PersonQuery) (response fun.PersonList, err common.HttpError)

func (*PersonManager) UpdatePerson

func (p *PersonManager) UpdatePerson(c context.Context, id string, request fun.PersonRequest) (err common.HttpError)

type PersonManagerInterface

type PersonManagerInterface interface {
	CreatePerson(c context.Context, request fun.PersonRequest) (person fun.Person, err common.HttpError)
	DeletePerson(c context.Context, id string) (err common.HttpError)
	UpdatePerson(c context.Context, id string, request fun.PersonRequest) (err common.HttpError)

	ListPersons(c context.Context, query fun.PersonQuery) (response fun.PersonList, err common.HttpError)
	GetPerson(c context.Context, id string) (person fun.Person, err common.HttpError)
	ListPersonAudit(c context.Context, id string) (response []fun.PersonAudit, err common.HttpError)
}

type SeatManager

type SeatManager struct {
	SeatPublisher publisher.SeatAllocationPublisher
}

func NewSeatManager

func NewSeatManager(seatPublisher publisher.SeatAllocationPublisher) *SeatManager

NewSeatManager constructs a seat-only manager that publishes seat events.

func (*SeatManager) AllocateSeat

func (sm *SeatManager) AllocateSeat(ctx context.Context, cmd fun.AllocateSeatCmdV1) common.HttpError

AllocateSeat processes AllocateSeat command and emits SeatReserved or SeatWaitlisted. On technical failure it returns an error; waitlist is not a failure. No DB writes here; persistence happens in subsequent event handlers.

func (*SeatManager) PublishAllocateSeat

func (sm *SeatManager) PublishAllocateSeat(ctx context.Context, enrollment fun.Enrollment) common.HttpError

PublishAllocateSeat emits the AllocateSeat command for async processing.

type SeatManagerInterface

type SeatManagerInterface interface {
	PublishAllocateSeat(ctx context.Context, enrollment fun.Enrollment) common.HttpError
	AllocateSeat(ctx context.Context, cmd fun.AllocateSeatCmdV1) common.HttpError
}

SeatManagerInterface handles seat-related saga processing and publishing. PublishAllocateSeat emits AllocateSeat command (C2) downstream. AllocateSeat decides reservation vs waitlist and emits the appropriate seat event; on capacity-unavailable it returns an error to trigger middleware retry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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