Documentation
¶
Overview ¶
Package intermediate serves as the foundation of the directory.example microservice.
The directory microservice exposes a RESTful API for persisting personal records in a SQL database.
Index ¶
- 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 ToDo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
Intermediate extends and customizes the generic base connector. Code generated microservices then extend the intermediate.
func NewService ¶
func NewService(impl ToDo, version int) *Intermediate
NewService creates a new intermediate service.
func (*Intermediate) SQL ¶
func (svc *Intermediate) SQL() (dsn string)
SQL is the connection string to the database.
func (*Intermediate) SetSQL ¶
func (svc *Intermediate) SetSQL(dsn string) error
SetSQL sets the value of the configuration property. This action is restricted to the TESTING deployment in which the fetching of values from the configurator is disabled.
SQL is the connection string to the database.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the directory.example microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Create ¶
func (svc *Mock) Create(ctx context.Context, httpRequestBody directoryapi.Person) (key directoryapi.PersonKey, err error)
Create runs the mock handler set by MockCreate.
func (*Mock) Load ¶
func (svc *Mock) Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
Load runs the mock handler set by MockLoad.
func (*Mock) LoadByEmail ¶
func (svc *Mock) LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
LoadByEmail runs the mock handler set by MockLoadByEmail.
func (*Mock) MockCreate ¶
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 the Create endpoint.
func (*Mock) MockDelete ¶
func (svc *Mock) MockDelete(handler func(ctx context.Context, key directoryapi.PersonKey) (err error)) *Mock
MockDelete sets up a mock handler for the Delete endpoint.
func (*Mock) MockList ¶
func (svc *Mock) MockList(handler func(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)) *Mock
MockList sets up a mock handler for the List endpoint.
func (*Mock) MockLoad ¶
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 the Load endpoint.
func (*Mock) MockLoadByEmail ¶
func (svc *Mock) MockLoadByEmail(handler func(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)) *Mock
MockLoadByEmail sets up a mock handler for the LoadByEmail endpoint.
func (*Mock) MockUpdate ¶
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 the Update endpoint.
func (*Mock) OnShutdown ¶
OnShutdown is a no op.
func (*Mock) OnStartup ¶
OnStartup makes sure that the mock is not executed in a non-dev environment.
func (*Mock) Update ¶
func (svc *Mock) Update(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error)
Update runs the mock handler set by MockUpdate.
type ToDo ¶
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)
Load(ctx context.Context, key directoryapi.PersonKey) (httpResponseBody directoryapi.Person, err error)
Delete(ctx context.Context, key directoryapi.PersonKey) (err error)
Update(ctx context.Context, key directoryapi.PersonKey, httpRequestBody directoryapi.Person) (err error)
LoadByEmail(ctx context.Context, email string) (httpResponseBody directoryapi.Person, err error)
List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)
WebUI(w http.ResponseWriter, r *http.Request) (err error)
}
ToDo defines the interface that the microservice must implement. The intermediate delegates handling to this interface.