directory

package
v1.22.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = directoryapi.Hostname
	Version  = 280
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate added in v1.22.0

type Intermediate struct {
	*connector.Connector
	ToDo
}

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 NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

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) Delete added in v1.22.0

func (svc *Mock) Delete(ctx context.Context, key directoryapi.PersonKey) (err error)

Delete executes the mock handler.

func (*Mock) List added in v1.22.0

func (svc *Mock) List(ctx context.Context) (httpResponseBody []directoryapi.PersonKey, err error)

List 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) MockWebUI added in v1.22.0

func (svc *Mock) MockWebUI(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockWebUI sets up a mock handler for WebUI.

func (*Mock) OnShutdown added in v1.22.0

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup added in v1.22.0

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

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.

func (*Mock) WebUI added in v1.22.0

func (svc *Mock) WebUI(w http.ResponseWriter, r *http.Request) (err error)

WebUI 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 NewService

func NewService() *Service

NewService creates a new instance of the microservice.

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) Delete

func (svc *Service) Delete(ctx context.Context, key directoryapi.PersonKey) (err error)

Delete removes a person from the directory.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

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

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

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.

func (*Service) WebUI

func (svc *Service) WebUI(w http.ResponseWriter, r *http.Request) (err error)

WebUI provides a form for making web requests to the CRUD endpoints.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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