Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (_c Client) Create(ctx context.Context, httpRequestBody Person) (key PersonKey, err error)
- func (_c Client) Delete(ctx context.Context, key PersonKey) (err error)
- func (_c Client) ForHost(host string) Client
- func (_c Client) List(ctx context.Context) (httpResponseBody []PersonKey, err error)
- func (_c Client) Load(ctx context.Context, key PersonKey) (httpResponseBody Person, err error)
- func (_c Client) LoadByEmail(ctx context.Context, email string) (httpResponseBody Person, err error)
- func (_c Client) Update(ctx context.Context, key PersonKey, httpRequestBody Person) (err error)
- func (_c Client) WebUI(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) WithOptions(opts ...pub.Option) Client
- type CreateIn
- type CreateOut
- type CreateResponse
- type DeleteIn
- type DeleteOut
- type DeleteResponse
- type Hook
- type ListIn
- type ListOut
- type ListResponse
- type LoadByEmailIn
- type LoadByEmailOut
- type LoadByEmailResponse
- type LoadIn
- type LoadOut
- type LoadResponse
- type MulticastClient
- func (_c MulticastClient) Create(ctx context.Context, httpRequestBody Person) <-chan *CreateResponse
- func (_c MulticastClient) Delete(ctx context.Context, key PersonKey) <-chan *DeleteResponse
- func (_c MulticastClient) ForHost(host string) MulticastClient
- func (_c MulticastClient) List(ctx context.Context) <-chan *ListResponse
- func (_c MulticastClient) Load(ctx context.Context, key PersonKey) <-chan *LoadResponse
- func (_c MulticastClient) LoadByEmail(ctx context.Context, email string) <-chan *LoadByEmailResponse
- func (_c MulticastClient) Update(ctx context.Context, key PersonKey, httpRequestBody Person) <-chan *UpdateResponse
- func (_c MulticastClient) WebUI(ctx context.Context, method string, relativeURL string, body any) <-chan *pub.Response
- func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
- type MulticastTrigger
- type Person
- type PersonKey
- type UpdateIn
- type UpdateOut
- type UpdateResponse
Constants ¶
const ( RouteOfCreate = `/persons` // MARKER: Create RouteOfLoad = `/persons/key/{key}` // MARKER: Load RouteOfDelete = `/persons/key/{key}` // MARKER: Delete RouteOfUpdate = `/persons/key/{key}` // MARKER: Update RouteOfLoadByEmail = `/persons/email/{email}` // MARKER: LoadByEmail RouteOfList = `/persons` // MARKER: List RouteOfWebUI = `/web-ui` // MARKER: WebUI )
Endpoint routes.
const Hostname = "directory.example"
Hostname is the default hostname of the microservice.
Variables ¶
var ( URLOfCreate = httpx.JoinHostAndPath(Hostname, RouteOfCreate) // MARKER: Create URLOfLoad = httpx.JoinHostAndPath(Hostname, RouteOfLoad) // MARKER: Load URLOfDelete = httpx.JoinHostAndPath(Hostname, RouteOfDelete) // MARKER: Delete URLOfUpdate = httpx.JoinHostAndPath(Hostname, RouteOfUpdate) // MARKER: Update URLOfLoadByEmail = httpx.JoinHostAndPath(Hostname, RouteOfLoadByEmail) // MARKER: LoadByEmail URLOfList = httpx.JoinHostAndPath(Hostname, RouteOfList) // MARKER: List URLOfWebUI = httpx.JoinHostAndPath(Hostname, RouteOfWebUI) // MARKER: WebUI )
Endpoint URLs.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight proxy for making unicast calls to the microservice.
func (Client) ForHost ¶
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (Client) LoadByEmail ¶
func (_c Client) LoadByEmail(ctx context.Context, email string) (httpResponseBody Person, err error)
LoadByEmail looks up a person in the directory by their email.
func (Client) WebUI ¶
func (_c Client) WebUI(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
WebUI provides a form for making web requests to the CRUD endpoints.
If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.
type CreateIn ¶
type CreateIn struct {
HTTPRequestBody Person `json:"-"`
}
CreateIn are the input arguments of Create.
type CreateOut ¶
type CreateOut struct {
Key PersonKey `json:"key,omitzero"`
}
CreateOut are the return values of Create.
type CreateResponse ¶
type CreateResponse struct {
HTTPResponse *http.Response
// contains filtered or unexported fields
}
CreateResponse is the response to Create.
func (*CreateResponse) Get ¶
func (_res *CreateResponse) Get() (key PersonKey, err error)
Get retrieves the return values.
type DeleteIn ¶
type DeleteIn struct {
Key PersonKey `json:"key,omitzero"`
}
DeleteIn are the input arguments of Delete.
type DeleteResponse ¶
type DeleteResponse struct {
HTTPResponse *http.Response
// contains filtered or unexported fields
}
DeleteResponse is the response to Delete.
func (*DeleteResponse) Get ¶
func (_res *DeleteResponse) Get() (err error)
Get retrieves the return values.
type Hook ¶ added in v1.22.0
type Hook struct {
// contains filtered or unexported fields
}
Hook assists in the subscription to the events of the microservice.
func NewHook ¶ added in v1.22.0
func NewHook(listener service.Subscriber) Hook
NewHook creates a new hook to the events of the microservice.
type ListOut ¶
type ListOut struct {
HTTPResponseBody []PersonKey `json:"httpResponseBody,omitzero"`
}
ListOut are the return values of List.
type ListResponse ¶
ListResponse is the response to List.
func (*ListResponse) Get ¶
func (_res *ListResponse) Get() (httpResponseBody []PersonKey, err error)
Get retrieves the return values.
type LoadByEmailIn ¶
type LoadByEmailIn struct {
Email string `json:"email,omitzero"`
}
LoadByEmailIn are the input arguments of LoadByEmail.
type LoadByEmailOut ¶
type LoadByEmailOut struct {
HTTPResponseBody Person `json:"httpResponseBody,omitzero"`
}
LoadByEmailOut are the return values of LoadByEmail.
type LoadByEmailResponse ¶
type LoadByEmailResponse struct {
HTTPResponse *http.Response
// contains filtered or unexported fields
}
LoadByEmailResponse is the response to LoadByEmail.
func (*LoadByEmailResponse) Get ¶
func (_res *LoadByEmailResponse) Get() (httpResponseBody Person, err error)
Get retrieves the return values.
type LoadIn ¶
type LoadIn struct {
Key PersonKey `json:"key,omitzero"`
}
LoadIn are the input arguments of Load.
type LoadOut ¶
type LoadOut struct {
HTTPResponseBody Person `json:"httpResponseBody,omitzero"`
}
LoadOut are the return values of Load.
type LoadResponse ¶
LoadResponse is the response to Load.
func (*LoadResponse) Get ¶
func (_res *LoadResponse) Get() (httpResponseBody Person, err error)
Get retrieves the return values.
type MulticastClient ¶
type MulticastClient struct {
// contains filtered or unexported fields
}
MulticastClient is a lightweight proxy for making multicast calls to the microservice.
func NewMulticastClient ¶
func NewMulticastClient(caller service.Publisher) MulticastClient
NewMulticastClient creates a new multicast client proxy to the microservice.
func (MulticastClient) Create ¶
func (_c MulticastClient) Create(ctx context.Context, httpRequestBody Person) <-chan *CreateResponse
Create registers the person in the directory.
func (MulticastClient) Delete ¶
func (_c MulticastClient) Delete(ctx context.Context, key PersonKey) <-chan *DeleteResponse
Delete removes a person from the directory.
func (MulticastClient) ForHost ¶
func (_c MulticastClient) ForHost(host string) MulticastClient
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (MulticastClient) List ¶
func (_c MulticastClient) List(ctx context.Context) <-chan *ListResponse
List returns the keys of all the persons in the directory.
func (MulticastClient) Load ¶
func (_c MulticastClient) Load(ctx context.Context, key PersonKey) <-chan *LoadResponse
Load looks up a person in the directory.
func (MulticastClient) LoadByEmail ¶
func (_c MulticastClient) LoadByEmail(ctx context.Context, email string) <-chan *LoadByEmailResponse
LoadByEmail looks up a person in the directory by their email.
func (MulticastClient) Update ¶
func (_c MulticastClient) Update(ctx context.Context, key PersonKey, httpRequestBody Person) <-chan *UpdateResponse
Update updates the person's data in the directory.
func (MulticastClient) WebUI ¶
func (_c MulticastClient) WebUI(ctx context.Context, method string, relativeURL string, body any) <-chan *pub.Response
WebUI provides a form for making web requests to the CRUD endpoints.
If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.
func (MulticastClient) WithOptions ¶ added in v1.13.1
func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
WithOptions returns a copy of the client with options to be applied to requests.
type MulticastTrigger ¶ added in v1.22.0
type MulticastTrigger struct {
// contains filtered or unexported fields
}
MulticastTrigger is a lightweight proxy for triggering the events of the microservice.
func NewMulticastTrigger ¶ added in v1.22.0
func NewMulticastTrigger(caller service.Publisher) MulticastTrigger
NewMulticastTrigger creates a new multicast trigger of events of the microservice.
func (MulticastTrigger) ForHost ¶ added in v1.22.0
func (_c MulticastTrigger) ForHost(host string) MulticastTrigger
ForHost returns a copy of the trigger with a different hostname to be applied to requests.
func (MulticastTrigger) WithOptions ¶ added in v1.22.0
func (_c MulticastTrigger) WithOptions(opts ...pub.Option) MulticastTrigger
WithOptions returns a copy of the trigger with options to be applied to requests.
type Person ¶
type Person struct {
Birthday time.Time `json:"birthday,omitzero"`
Email string `json:"email,omitzero"`
FirstName string `json:"firstName,omitzero"`
Key PersonKey `json:"key,omitzero"`
LastName string `json:"lastName,omitzero"`
}
Person is a personal record that is registered in the directory. First and last name and email are required. Birthday is optional.
type UpdateResponse ¶
type UpdateResponse struct {
HTTPResponse *http.Response
// contains filtered or unexported fields
}
UpdateResponse is the response to Update.
func (*UpdateResponse) Get ¶
func (_res *UpdateResponse) Get() (err error)
Get retrieves the return values.