Documentation ¶
Overview ¶
Package tenantid is a client library for the Tenant Translator service. The service provides translation between different tenant identifiers.
Index ¶
- type BatchTranslator
- type HttpRequestDoer
- type TenantNotFoundError
- type TranslationResult
- type Translator
- type TranslatorOption
- func WithDoer(doer HttpRequestDoer) TranslatorOption
- func WithDoerWrapper(fn func(HttpRequestDoer) HttpRequestDoer) TranslatorOption
- func WithMetrics() TranslatorOption
- func WithMetricsWithCustomRegisterer(registerer prometheus.Registerer) TranslatorOption
- func WithTimeout(timeout time.Duration) TranslatorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchTranslator ¶
type BatchTranslator interface { // Converts a slice of EANs (EBS account number) to org_ids EANsToOrgIDs(ctx context.Context, eans []string) (results []TranslationResult, err error) // Converts a slice of org_ids to EANs (EBS account number) OrgIDsToEANs(ctx context.Context, orgIDs []string) (results []TranslationResult, err error) }
Provides translation between tenant identifiers.
type HttpRequestDoer ¶
abstraction of http.Client
type TenantNotFoundError ¶
type TenantNotFoundError struct {
// contains filtered or unexported fields
}
Indicates that no tenant matches the provided identifier
func (*TenantNotFoundError) Error ¶
func (e *TenantNotFoundError) Error() string
type TranslationResult ¶
Holds the result of tenant identifier translation
type Translator ¶
type Translator interface { BatchTranslator // Converts an EAN (EBS account number) to org_id. // Returns TenantNotFoundError (second return value) if the EAN is not known. EANToOrgID(ctx context.Context, ean string) (orgId string, err error) // Converts an org_id to EAN (EBS account number). // Returns nil if the org_id belongs to an anemic tenant or the org_id is not known. OrgIDToEAN(ctx context.Context, orgId string) (ean *string, err error) }
Provides translation between tenant identifiers. Namely, it converts an org_id to EAN (EBS account number) and vice versa. Both single-operation and batch variants are provided
func NewTranslator ¶
func NewTranslator(serviceHost string, options ...TranslatorOption) Translator
NewTranslator returns a new translator instance configured with the provided options
func NewTranslatorMock ¶
func NewTranslatorMock() Translator
NewTranslatorMock returns a mock implementation of translator with a predefined mapping.
func NewTranslatorMockWithMapping ¶
func NewTranslatorMockWithMapping(mapping map[string]*string) Translator
NewTranslatorMockWithMapping returns a mock implementation of translator that operates on the given mapping.
type TranslatorOption ¶
type TranslatorOption interface { // Options may need to be applied in certain order (e.g. timeout-setting should be applied before an option that wraps the doer) // Priority lets us have complete ordering of all options // Options are applied in ascending priority (highest priority options go last) Priority() int // contains filtered or unexported methods }
func WithDoer ¶
func WithDoer(doer HttpRequestDoer) TranslatorOption
WithDoer allow a custom http.Client to be provided.
func WithDoerWrapper ¶
func WithDoerWrapper(fn func(HttpRequestDoer) HttpRequestDoer) TranslatorOption
WithDoerWrapper allow for the default http.Client to be wrapped by a custom decorator.
func WithMetrics ¶
func WithMetrics() TranslatorOption
WithMetrics registers a new histogram measuring latency with the default prometheus Registerer
func WithMetricsWithCustomRegisterer ¶
func WithMetricsWithCustomRegisterer(registerer prometheus.Registerer) TranslatorOption
WithMetricsWithCustomRegisterer registers a new histogram measuring latency with the provided prometheus Registerer
func WithTimeout ¶
func WithTimeout(timeout time.Duration) TranslatorOption
WithTimeout allows a custom timeout value to be defined. The default value of 10 seconds is used otherwise.