Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Thing ¶
type Thing struct { ThingID int64 `json:"thingID" db:"thingID"` Name string `json:"name" db:"name"` CreatedAt time.Time `json:"createdAt" db:"createdAt"` ModifiedAt time.Time `json:"modifiedAt" db:"modifiedAt"` }
Thing defines a single thing.
type ThingArgs ¶
type ThingArgs struct {
ThingID int64 `param:"thingID" query:"thingID"`
}
ThingArgs are used to retrieve a single thing.
type ThingCreate ¶
type ThingCreate struct { Name string `json:"name" db:"name"` // CreatedAt set in the data layer before storing - could also be a db default value of current_date. CreatedAt time.Time `json:"-" db:"createdAt"` }
ThingCreate is used to create a new thing.
type ThingReader ¶
type ThingReader interface { Thing(ctx context.Context, args ThingArgs) (*Thing, error) Things(ctx context.Context) ([]*Thing, error) }
ThingReader is used to read thing or things from a data store.
type ThingReaderWriter ¶
type ThingReaderWriter interface { ThingReader ThingWriter }
ThingReaderWriter combines the reader and writer interface to define a read/write datastore for working with things.
type ThingService ¶
type ThingService interface { Thing(ctx context.Context, args ThingArgs) (*Thing, error) Things(ctx context.Context) ([]*Thing, error) Create(ctx context.Context, req ThingCreate) (*Thing, error) Update(ctx context.Context, args ThingArgs, req ThingUpdate) (*Thing, error) Delete(ctx context.Context, args ThingArgs) error }
ThingService is used to enforce business rules, orchestrate data store calls and raise business events.
type ThingUpdate ¶
type ThingUpdate struct { Name string `json:"name" db:"name"` // ModifiedAt used to set the update time in the data layer. ModifiedAt time.Time `json:"-" db:"modifiedAt"` }
ThingUpdate is used to update a thing.
type ThingWriter ¶
type ThingWriter interface { Create(ctx context.Context, args ThingCreate) (*Thing, error) Update(ctx context.Context, args ThingArgs, req ThingUpdate) (*Thing, error) Delete(ctx context.Context, args ThingArgs) error }
ThingWriter can be implemented to write and modify things stored in a datastore.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
Package mocks requires the github.com/matryer/moq lib to be installed.
|
Package mocks requires the github.com/matryer/moq lib to be installed. |
Click to show internal directories.
Click to hide internal directories.