Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)
- func (svc *Mock) Delete(ctx context.Context, key directoryapi.PersonKey) (err error)
- func (svc *Mock) List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)
- func (svc *Mock) Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
- func (svc *Mock) LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
- func (svc *Mock) MockCreate(...) *Mock
- func (svc *Mock) MockDelete(handler func(ctx context.Context, key directoryapi.PersonKey) (err error)) *Mock
- func (svc *Mock) MockList(...) *Mock
- func (svc *Mock) MockLoad(...) *Mock
- func (svc *Mock) MockLoadByEmail(...) *Mock
- func (svc *Mock) MockUpdate(handler func(ctx context.Context, key directoryapi.PersonKey, ...) (err error)) *Mock
- func (svc *Mock) MockWebUI(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) Update(ctx context.Context, key directoryapi.PersonKey, ...) (err error)
- func (svc *Mock) WebUI(w http.ResponseWriter, r *http.Request) (err error)
- type Service
- func (svc *Service) Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)
- func (svc *Service) Delete(ctx context.Context, key directoryapi.PersonKey) (err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)
- func (svc *Service) Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
- func (svc *Service) LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) Update(ctx context.Context, key directoryapi.PersonKey, ...) (err error)
- func (svc *Service) WebUI(w http.ResponseWriter, r *http.Request) (err error)
- type ToDo
Constants ¶
const ( Hostname = directoryapi.Hostname Version = 280 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶ added in v1.22.0
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶ added in v1.22.0
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
func (*Intermediate) SQL ¶ added in v1.22.0
func (svc *Intermediate) SQL() (dsn string)
SQL is the connection string to the database.
func (*Intermediate) SetSQL ¶ added in v1.22.0
func (svc *Intermediate) SetSQL(dsn string) (err error)
SetSQL sets the value of the configuration property.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Create ¶ added in v1.22.0
func (svc *Mock) Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)
Create executes the mock handler.
func (*Mock) Load ¶ added in v1.22.0
func (svc *Mock) Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
Load executes the mock handler.
func (*Mock) LoadByEmail ¶ added in v1.22.0
func (svc *Mock) LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
LoadByEmail executes the mock handler.
func (*Mock) MockCreate ¶ added in v1.22.0
func (svc *Mock) MockCreate(handler func(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)) *Mock
MockCreate sets up a mock handler for Create.
func (*Mock) MockDelete ¶ added in v1.22.0
func (svc *Mock) MockDelete(handler func(ctx context.Context, key directoryapi.PersonKey) (err error)) *Mock
MockDelete sets up a mock handler for Delete.
func (*Mock) MockList ¶ added in v1.22.0
func (svc *Mock) MockList(handler func(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)) *Mock
MockList sets up a mock handler for List.
func (*Mock) MockLoad ¶ added in v1.22.0
func (svc *Mock) MockLoad(handler func(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)) *Mock
MockLoad sets up a mock handler for Load.
func (*Mock) MockLoadByEmail ¶ added in v1.22.0
func (svc *Mock) MockLoadByEmail(handler func(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)) *Mock
MockLoadByEmail sets up a mock handler for LoadByEmail.
func (*Mock) MockUpdate ¶ added in v1.22.0
func (svc *Mock) MockUpdate(handler func(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error)) *Mock
MockUpdate sets up a mock handler for Update.
func (*Mock) OnShutdown ¶ added in v1.22.0
OnShutdown is called when the microservice is shut down.
func (*Mock) Update ¶ added in v1.22.0
func (svc *Mock) Update(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error)
Update executes the mock handler.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
// contains filtered or unexported fields
}
Service implements the directory.example microservice.
The directory microservice exposes a RESTful API for persisting personal records in a SQL database.
func (*Service) Create ¶
func (svc *Service) Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)
Create registers the person in the directory.
func (*Service) List ¶
func (svc *Service) List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)
List returns the keys of all the persons in the directory.
func (*Service) Load ¶
func (svc *Service) Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
Load looks up a person in the directory.
func (*Service) LoadByEmail ¶
func (svc *Service) LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
LoadByEmail looks up a person in the directory by their email.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
func (*Service) Update ¶
func (svc *Service) Update(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error)
Update updates the person's data in the directory.
type ToDo ¶ added in v1.22.0
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error) // MARKER: Create
Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error) // MARKER: Load
Delete(ctx context.Context, key directoryapi.PersonKey) (err error) // MARKER: Delete
Update(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error) // MARKER: Update
LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error) // MARKER: LoadByEmail
List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error) // MARKER: List
WebUI(w http.ResponseWriter, r *http.Request) (err error) // MARKER: WebUI
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.