directoryapi

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const Hostname = "directory.example"

Hostname is the default hostname of the microservice.

Variables

View Source
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 NewClient

func NewClient(caller service.Publisher) Client

NewClient creates a new unicast client proxy to the microservice.

func (Client) Create

func (_c Client) Create(ctx context.Context, httpRequestBody Person) (key PersonKey, err error)

Create registers the person in the directory.

func (Client) Delete

func (_c Client) Delete(ctx context.Context, key PersonKey) (err error)

Delete removes a person from the directory.

func (Client) ForHost

func (_c Client) ForHost(host string) Client

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (Client) List

func (_c Client) List(ctx context.Context) (httpResponseBody []PersonKey, err error)

List returns the keys of all the persons in the directory.

func (Client) Load

func (_c Client) Load(ctx context.Context, key PersonKey) (httpResponseBody Person, err error)

Load looks up a person in the directory.

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

func (_c Client) Update(ctx context.Context, key PersonKey, httpRequestBody Person) (err error)

Update updates the person's data in the directory.

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.

func (Client) WithOptions added in v1.13.1

func (_c Client) WithOptions(opts ...pub.Option) Client

WithOptions returns a copy of the client with options to be applied to requests.

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 DeleteOut

type DeleteOut struct {
}

DeleteOut are the return values 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.

func (Hook) ForHost added in v1.22.0

func (c Hook) ForHost(host string) Hook

ForHost returns a copy of the hook with a different hostname to be applied to the subscription.

func (Hook) WithOptions added in v1.22.0

func (c Hook) WithOptions(opts ...sub.Option) Hook

WithOptions returns a copy of the hook with options to be applied to subscriptions.

type ListIn

type ListIn struct {
}

ListIn are the input arguments of List.

type ListOut

type ListOut struct {
	HTTPResponseBody []PersonKey `json:"httpResponseBody,omitzero"`
}

ListOut are the return values of List.

type ListResponse

type ListResponse struct {
	HTTPResponse *http.Response
	// contains filtered or unexported fields
}

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

type LoadResponse struct {
	HTTPResponse *http.Response
	// contains filtered or unexported fields
}

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.

func (*Person) Validate

func (person *Person) Validate() error

Validate validates the field of the person. First and last name and email are required. Optional birthday must be in the past.

type PersonKey

type PersonKey int

PersonKey is the primary key of the person.

type UpdateIn

type UpdateIn struct {
	Key             PersonKey `json:"key,omitzero"`
	HTTPRequestBody Person    `json:"-"`
}

UpdateIn are the input arguments of Update.

type UpdateOut

type UpdateOut struct {
}

UpdateOut are the return values of Update.

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.

Jump to

Keyboard shortcuts

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