azcore

package
v0.0.0-...-9740126 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 7 Imported by: 6

Documentation

Overview

Package azcore contains all fundamental functionality of Go implementation of AlloyZeus.

Index

Constants

View Source
const (
	ErrUserContextRequired    = constantErrorDescriptor("user context required")
	ErrServiceContextRequired = constantErrorDescriptor("service context required")
)
View Source
const AZCorePackageIsVersion1 = true

AZCorePackageIsVersion1 is referenced from generated files to assert that that code is compatible with this version of the azcore package.

View Source
const (
	ErrOperationNotAllowed = constantErrorDescriptor("operation not allowed")
)

Variables

View Source
var ErrServiceMethodNotImplemented = &ServiceMethodInternalErrorMsg{msg: "not implemented"}

ErrServiceMethodNotImplemented is usually used when a method is unable to achieve its objective because some part of it is unimplemented.

Analogous to HTTP's 501 status code and gRPC's 12 status code.

Functions

func ServiceContextRequiredError

func ServiceContextRequiredError(details error) error

func UserContextRequiredError

func UserContextRequiredError(details error) error

Types

type Adjunct

type Adjunct interface {
	AZAdjunct()
}

Adjunct abstracts adjuncts.

type AdjunctEntityAttributes

type AdjunctEntityAttributes interface {
	Attributes

	AZAdjunctEntityAttributes()
}

AdjunctEntityAttributes abstracts adjunct entity attributes.

type AdjunctEntityID

type AdjunctEntityID[IDNumT AdjunctEntityIDNum] interface {
	azid.ID[IDNumT]

	AZAdjunctEntityID()
}

An AdjunctEntityID is an identifier of an adjunt-entity.

type AdjunctEntityIDNum

type AdjunctEntityIDNum interface {
	azid.IDNum

	AdjunctEntityIDNumMethods
}

AdjunctEntityIDNum abstracts adjunct entity IDs.

type AdjunctEntityIDNumMethods

type AdjunctEntityIDNumMethods interface {
	AZAdjunctEntityIDNum()
}

type AdjunctEntityService

type AdjunctEntityService interface {
	Service

	AZAdjunctEntityService()
}

AdjunctEntityService abstracts adjunct entity services.

type AdjunctEntityServiceBase

type AdjunctEntityServiceBase struct{}

AdjunctEntityServiceBase provides a base for AdjunctEntityService implementations. This implementation is shared by client and server implementations.

func (*AdjunctEntityServiceBase) AZAdjunctEntityService

func (*AdjunctEntityServiceBase) AZAdjunctEntityService()

AZAdjunctEntityService is required for conformance with AdjunctEntityService.

func (*AdjunctEntityServiceBase) AZService

func (*AdjunctEntityServiceBase) AZService()

AZService is required for conformance with Service.

type AdjunctEntityServiceClient

type AdjunctEntityServiceClient interface {
	AdjunctEntityService
	ServiceClient

	AZAdjunctEntityServiceClient()
}

AdjunctEntityServiceClient abstracts adjunct entity service client implementations.

type AdjunctEntityServiceClientBase

type AdjunctEntityServiceClientBase struct {
	AdjunctEntityServiceBase
}

AdjunctEntityServiceClientBase provides a base for AdjunctEntityServiceClient implementations.

func (*AdjunctEntityServiceClientBase) AZAdjunctEntityServiceClient

func (*AdjunctEntityServiceClientBase) AZAdjunctEntityServiceClient()

AZAdjunctEntityServiceClient is required for comformance with AdjunctEntityServiceClient.

func (*AdjunctEntityServiceClientBase) AZServiceClient

func (*AdjunctEntityServiceClientBase) AZServiceClient()

AZServiceClient is required for conformance with ServiceClient.

type AdjunctEntityServiceServer

type AdjunctEntityServiceServer interface {
	AdjunctEntityService
	ServiceServer

	AZAdjunctEntityServiceServer()
}

AdjunctEntityServiceServer abstracts adjunct entity service client implementations.

type AdjunctEntityServiceServerBase

type AdjunctEntityServiceServerBase struct {
	AdjunctEntityServiceBase
}

AdjunctEntityServiceServerBase provides a base for AdjunctEntityServiceServer implementations.

func (*AdjunctEntityServiceServerBase) AZAdjunctEntityServiceServer

func (*AdjunctEntityServiceServerBase) AZAdjunctEntityServiceServer()

AZAdjunctEntityServiceServer is required for comformance with AdjunctEntityServiceServer.

func (*AdjunctEntityServiceServerBase) AZServiceServer

func (*AdjunctEntityServiceServerBase) AZServiceServer()

AZServiceServer is required for conformance with ServiceServer.

type Attributes

type Attributes interface {
	AZAttributes()
}

Attributes abstracts attributes.

type Context

type Context interface {
	context.Context

	AZContext()
}

Context is a generalized context for all service methods.

type Entity

type Entity interface {
	AZEntity()
}

Entity defines the contract for all its concrete implementations.

For now, this is unused.

type EntityAttributes

type EntityAttributes interface {
	Attributes

	AZEntityAttributes()
}

An EntityAttributes instance contains the actual attributes of an entity. It's on itself is a value object and does not have any identity.

An EntityAttributes instance doesn't hold the ID of its entity instance. For the structure that holds both the ID and its attributes, see KeyedEntityAttributes, which pratically contains a pair of attributes -- the ID of the entity and the of attributes of the entity.

type EntityCreationEvent

type EntityCreationEvent[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	EntityCreationInfoT EntityCreationInfo[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT],
] interface {
	AZEntityCreationEvent()

	CreationInfo() EntityCreationInfoT
}

EntityCreationEvent is the abstraction for all entity creation events.

type EntityCreationInfo

type EntityCreationInfo[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
] interface {
	OperationInfo[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT]
}

EntityCreationInfo holds information about the creation of an entity.

type EntityCreationInputContext

type EntityCreationInputContext[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
] interface {
	ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceMethodIdempotencyKeyT]

	AZEntityCreationInputContext()
}

EntityCreationInputContext is the abstraction for all entity creation call input contexts.

type EntityCreationOutput

type EntityCreationOutput[
	IDNumT EntityIDNum,
	IDT EntityID[IDNumT],
	RevisionNumberT EntityRevisionNumber,
	DeletionInfoT EntityDeletionInfo,
	InstanceInfoT EntityInstanceInfo[
		RevisionNumberT, DeletionInfoT],
] struct {
	InstanceID   IDT
	InitialState InstanceInfoT
}

type EntityCreationOutputContext

type EntityCreationOutputContext interface {
	ServiceMethodCallOutputContext

	AZEntityCreationOutputContext()
}

EntityCreationOutputContext is the abstraction for all entity creation call output contexts.

type EntityDeletionInfo

type EntityDeletionInfo interface {
	// Deleted returns true when the instance is positively deleted.
	Deleted() bool
}

EntityDeletionInfo provides information about the deletion of an entity instance.

type EntityDeletionInfoBase

type EntityDeletionInfoBase struct {
	Deleted_ bool
}

EntityDeletionInfoBase is a base implementation of EntityDeletionInfo with all attributes are public.

func (EntityDeletionInfoBase) Deleted

func (deletionInfo EntityDeletionInfoBase) Deleted() bool

Deleted conforms EntityDeletionInfo interface.

type EntityEvent

type EntityEvent interface {
	Event

	AZEntityEvent()
}

EntityEvent defines the contract for all event types of the entity.

type EntityEventBase

type EntityEventBase struct {
	EventBase
}

EntityEventBase provides a basic implementation for all Entity events.

func (EntityEventBase) AZEntityEvent

func (EntityEventBase) AZEntityEvent()

AZEntityEvent is required by EntityEvent.

type EntityID

type EntityID[IDNumT EntityIDNum] interface {
	azid.ID[IDNumT]

	AZEntityID()
}

An EntityID is an identifier of an entity.

type EntityIDNum

type EntityIDNum interface {
	azid.IDNum

	EntityIDNumMethods
}

EntityIDNum is the unique or local part of an entity identifier.

TODO: this is a value-object.

type EntityIDNumMethods

type EntityIDNumMethods interface {
	AZEntityIDNum()
}

type EntityInstanceInfo

type EntityInstanceInfo[
	RevisionNumberT EntityRevisionNumber,
	DeletionInfoT EntityDeletionInfo,
] interface {
	RevisionNumber() RevisionNumberT

	// Deletion returns a detailed information about the deletion if
	// the instance has been deleted.
	Deletion() *DeletionInfoT
	// IsDeleted returns true if the instance has been deleted.
	IsDeleted() bool
}

EntityInstanceInfo holds information about an instance of entity, i.e., metadata of an instance of entity. It doesn't contain the attributes of the instance itself.

type EntityInstanceInfoBase

type EntityInstanceInfoBase[
	RevisionNumberT EntityRevisionNumber,
	DeletionInfoT EntityDeletionInfo,
] struct {
	RevisionNumber_ RevisionNumberT
	Deletion_       *DeletionInfoT
}

EntityInstanceInfoBase is a base implementation of EntityInstanceInfo with all attributes are public.

func (EntityInstanceInfoBase[RevisionNumberT, DeletionInfoT]) Deletion

func (instanceInfo EntityInstanceInfoBase[
	RevisionNumberT, DeletionInfoT,
]) Deletion() *DeletionInfoT

func (EntityInstanceInfoBase[RevisionNumberT, DeletionInfoT]) IsDeleted

func (instanceInfo EntityInstanceInfoBase[
	RevisionNumberT, DeletionInfoT,
]) IsDeleted() bool

func (EntityInstanceInfoBase[RevisionNumberT, DeletionInfoT]) RevisionNumber

func (instanceInfo EntityInstanceInfoBase[
	RevisionNumberT, DeletionInfoT,
]) RevisionNumber() RevisionNumberT

type EntityMethodCallInputContext

type EntityMethodCallInputContext[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
] interface {
	EntityMethodContext
	ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceMethodIdempotencyKeyT,
	]
}

EntityMethodCallInputContext is an abstraction for all method call input contexts.

type EntityMethodCallOutputContext

type EntityMethodCallOutputContext interface {
	EntityMethodContext
	ServiceMethodCallOutputContext
}

EntityMethodCallOutputContext is an abstraction for all method call output contexts.

type EntityMethodContext

type EntityMethodContext interface {
	ServiceMethodContext
}

EntityMethodContext provides an abstraction for all operations which apply to entity instances.

type EntityMethodMessage

type EntityMethodMessage interface {
	ServiceMethodMessage

	EntityMethodContext() EntityMethodContext
}

EntityMethodMessage abstracts the messages, i.e., requests and responses.

type EntityMutatingContext

type EntityMutatingContext interface {
	EntityMethodContext
	ServiceMutatingMethodContext
}

EntityMutatingContext is a specialization of EntityOperationContext which is used for operations which make any change to the entity.

type EntityMutatingMessage

type EntityMutatingMessage interface {
	EntityMethodMessage
	ServiceMutatingMethodMessage

	EntityMutatingContext() EntityMutatingContext
}

EntityMutatingMessage abstracts entity mutating method requests and responses.

type EntityMutatingMethodCallContext

type EntityMutatingMethodCallContext[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodCallInputContextT ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceMethodIdempotencyKeyT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
] interface {
	EntityMutatingContext
	EntityMethodCallInputContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceMethodIdempotencyKeyT]
	ServiceMutatingMethodCallInputContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceMethodCallInputContextT, ServiceMethodIdempotencyKeyT]
}

EntityMutatingMethodCallContext provides an abstraction for input contexts for mutating method calls.

type EntityMutatingMethodCallOutputContext

type EntityMutatingMethodCallOutputContext interface {
	EntityMutatingContext
	EntityMethodCallOutputContext
	ServiceMutatingMethodCallOutputContext
}

EntityMutatingMethodCallOutputContext provides an abstraction for output contexts for mutating method calls.

type EntityRevisionNumber

type EntityRevisionNumber interface {
	int16 | int32 | int64
}

type EntityService

type EntityService interface {
	AZEntityService()
}

EntityService provides an abstraction for all entity services. This abstraction is used by both client and server.

type EntityServiceBase

type EntityServiceBase struct{}

EntityServiceBase provides a basic implementation for EntityService.

func (*EntityServiceBase) AZEntityService

func (*EntityServiceBase) AZEntityService()

AZEntityService is required for conformance with EntityService.

type EntityServiceClient

type EntityServiceClient interface {
	EntityService

	AZEntityServiceClient()
}

EntityServiceClient provides an abstraction for all entity service clients.

type EntityServiceServer

type EntityServiceServer interface {
	EntityService

	AZEntityServiceServer()
}

EntityServiceServer provides an abstraction for all entity service servers.

type Error

type Error error

Error is the module error type.

type Event

type Event interface {
	AZEvent()
}

Event provides a contract for all events in the system.

type EventBase

type EventBase struct{}

EventBase provides a common implementation for all events.

func (EventBase) AZEvent

func (EventBase) AZEvent()

AZEvent is required by Event

type HumanContext

type HumanContext interface {
	Context

	// AcceptLanguage is analogous to HTTP Accept-Language header field. The
	// languages must be ordered by the human's preference.
	// If the languages comes as weighted, as found in HTTP Accept-Language,
	// sort the languages by their weights then drop the weights.
	AcceptLanguage() []language.Tag
}

HumanContext is a specialized context, where current processing was initiated by a human.

type KeyedEntityAttributes

type KeyedEntityAttributes[
	EntityIDNumT EntityIDNum,
	EntityIDT EntityID[EntityIDNumT],
	EntityAttributesT EntityAttributes,
] struct {
	ID         EntityIDT
	Attributes EntityAttributesT
}

KeyedEntityAttributes is a self-identifying data structure that contains both the ID of the entity and its representing attributes.

TODO: an envelope with EntityInstanceInfo?

type OperationDelegationInfo

type OperationDelegationInfo[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
] interface {
	// ParentDelegationInfo returns the delegation parent of this delegation.
	ParentDelegationInfo() OperationDelegationInfo[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT]

	// Actor returns the subject who delegated the action. Must not be empty
	// in server, might be empty in clients, might be queryable.
	Actor() SessionSubjectT

	// Session returns the session by the actor to delegate the action.
	// Must not be empty in server, might be empty in clients.
	Session() SessionT
}

OperationDelegationInfo holds information about delegation for an action if that action was delegated.

TODO: actual info

type OperationInfo

type OperationInfo[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
] interface {
	// IdempotencyKey returns the idempotency key for this operation.
	IdempotencyKey() ServiceMethodIdempotencyKey

	// Actor returns the subject who executed the action. Must not be empty
	// in server, might be empty in clients, might be queryable.
	Actor() SessionSubjectT

	// Session returns the session by the actor to perform the action.
	// Must not be empty in server, might be empty in clients.
	Session() SessionT

	// DelegationInfo returns the information about the delegation if this
	// action was delegated to other subject or session.
	DelegationInfo() OperationDelegationInfo[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT]

	// Timestamp returns the time when the action made the effect. This should
	// be obtained from the lowest level, e.g., database or file system.
	//
	// An analogy: in ordering process in a restaurant, the
	// timestamp is the time when the cook declared that the food is ready
	// to be served.
	Timestamp() *time.Time
}

OperationInfo holds information about an action.

type RealmService

type RealmService interface {
	AZRealmService()
}

RealmService provides information about the realm.

A realm is a site or the whole service.

type RealmServiceServer

type RealmServiceServer interface {
	RealmService

	RealmName() string

	WebsiteURL() url.URL
}

RealmServiceServer provides contracts for a realm service.

type Service

type Service interface {
	AZService()
}

Service provides an abstraction for all services.

type ServiceClient

type ServiceClient interface {
	Service
	AZServiceClient()
}

ServiceClient provides an abstraction for all service clients.

type ServiceClientConfig

type ServiceClientConfig interface {
	ServiceConfig
}

ServiceClientConfig holds the configuration for a service client.

type ServiceClientError

type ServiceClientError interface {
	ServiceError

	AZServiceClientError()
}

ServiceClientError is an abstraction for all errors emitted by a service server.

type ServiceClientModule

type ServiceClientModule struct {
	ServiceClientConfigSkeleton func() ServiceClientConfig
	NewServiceClient            func(ServiceClientConfig) (ServiceClient, ServiceClientError)
}

ServiceClientModule provides all the required to instantiate a service client.

func (ServiceClientModule) AZServiceModule

func (ServiceClientModule) AZServiceModule()

AZServiceModule is required for conformance with ServiceModule.

type ServiceConfig

type ServiceConfig interface {
	AZServiceConfig()
}

ServiceConfig provides a contract for all of its implementations.

type ServiceContext

type ServiceContext interface {
	Context

	AZServiceContext()
}

ServiceContext is an abstraction for service-related contexts.

type ServiceError

type ServiceError interface {
	Error

	AZServiceError()
}

ServiceError is an abstraction for all errors emitted by a service.

type ServiceMethodCallContext

type ServiceMethodCallContext interface {
	ServiceMethodContext

	AZServiceMethodCallContext()

	// MethodName returns the name of the method or the endpoint.
	//
	// For HTTP, this method returns the method. For other protocols, it should
	// be the name of the method e.g., `getUser`.
	MethodName() string

	// ResourceID returns the identifier of the resource being accessed by
	// the call. For HTTP, it's the path. For other protocols, it should
	// be the identifier (ID) of the entity. If there's more than one
	// resources, e.g., a relationship between two entities, then it returns
	// the identifiers of the entities separated by commas.
	ResourceID() string
}

type ServiceMethodCallInput

type ServiceMethodCallInput[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
	InputContextT ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceMethodIdempotencyKeyT],
	InputDataT ServiceMethodCallInputData,
] struct {
	Context InputContextT
	Data    InputDataT
}

type ServiceMethodCallInputContext

type ServiceMethodCallInputContext[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
] interface {
	ServiceMethodCallContext

	AZServiceMethodCallInputContext()

	// Session returns the session for this context.
	Session() SessionT

	// IdempotencyKey is a key used to ensure that a distinct operation is
	// performed at most once.
	//
	// This key is different from request ID, where for the same operation,
	// there could be more than one requests in attempt to retry in the event
	// of transit error.
	IdempotencyKey() ServiceMethodIdempotencyKeyT

	// OriginInfo returns information about the system that made the call.
	OriginInfo() ServiceMethodCallOriginInfo
}

ServiceMethodCallInputContext provides an abstraction for all input contexts in method call inputs.

type ServiceMethodCallInputContextError

type ServiceMethodCallInputContextError interface {
	ServiceMethodCallInvocationError

	AZServiceMethodCallInputContextError()
}

ServiceMethodCallInputContextError provides information for request-context-related error. It is a sub-class of ServiceMethodCallInputError.

type ServiceMethodCallInputData

type ServiceMethodCallInputData interface {
}

ServiceMethodCallInputData abstracts method request body.

type ServiceMethodCallInputMetadata

type ServiceMethodCallInputMetadata interface {
}

type ServiceMethodCallInvocationError

type ServiceMethodCallInvocationError interface {
	ServiceMethodError

	AZServiceMethodCallInvocationError()
}

ServiceMethodCallInvocationError is a sub-class of ServiceMethodError which indicates that there's an error in the request.

This error class is analogous to HTTP's 4xx status codes.

TODO: sub-classes: acces, parameters, context

type ServiceMethodCallOriginInfo

type ServiceMethodCallOriginInfo struct {
	// Address returns the IP address or hostname where this call was initiated
	// from. This field might be empty if it's not possible to resolve
	// the address (e.g., the server is behind a proxy or a load-balancer and
	// they didn't forward the the origin IP).
	Address string

	// EnvironmentString returns some details of the environment,
	// might include application's version information, where the application
	// which made the request runs on. For web app, this method usually
	// returns the browser's user-agent string.
	EnvironmentString string

	// AcceptLanguage is analogous to HTTP Accept-Language header field. The
	// languages must be ordered by the human's preference.
	// If the languages comes as weighted, as found in HTTP Accept-Language,
	// sort the languages by their weights then drop the weights.
	AcceptLanguage []language.Tag

	// DateTime is the time of the caller device when the call was initiated.
	//
	// Analogous to HTTP Date header field.
	DateTime *time.Time
}

ServiceMethodCallOriginInfo holds information about a call's origin.

TODO: key-value custom data

type ServiceMethodCallOutputContext

type ServiceMethodCallOutputContext interface {
	//TODO: ServiceMethodCallContext, or keep it like this and
	// add a method to access the input context: MethodCallInputContext()
	ServiceMethodContext

	AZServiceMethodCallOutputContext()

	// Returns the error, if any.
	ServiceMethodErr() ServiceMethodError

	// Mutated returns true if the method made any changes to any state in the
	// server, even when the method did not succeed. It should not
	// return true if the change has been completely rolled-back before the
	// method returned this context.
	Mutated() bool
}

ServiceMethodCallOutputContext provides an abstraction for all output contexts in method call outputs.

TODO: listing of affected states with their respective revision ID. TODO: directive: done/end, redirect, retry (on failure; optionally with timing and retry count parameters or exponentially back-off parameters)

type ServiceMethodCallOutputContextBase

type ServiceMethodCallOutputContextBase struct {
	context.Context
	// contains filtered or unexported fields
}

ServiceMethodCallOutputContextBase is a base for ServiceMethodCallOutputContext implementations.

func NewMethodCallOutputContext

func NewMethodCallOutputContext(
	err ServiceMethodError,
	mutated bool,
) ServiceMethodCallOutputContextBase

NewMethodCallOutputContext creates a new instance of ServiceMethodCallOutputContext.

func (ServiceMethodCallOutputContextBase) AZContext

AZContext is required for conformance with Context.

func (ServiceMethodCallOutputContextBase) AZServiceContext

func (ServiceMethodCallOutputContextBase) AZServiceContext()

AZServiceContext is required for conformance with ServiceContext.

func (ServiceMethodCallOutputContextBase) AZServiceMethodCallOutputContext

func (ServiceMethodCallOutputContextBase) AZServiceMethodCallOutputContext()

AZServiceMethodCallOutputContext is required for conformance with ServiceMethodCallOutputContext.

func (ServiceMethodCallOutputContextBase) AZServiceMethodContext

func (ServiceMethodCallOutputContextBase) AZServiceMethodContext()

AZServiceMethodContext is required for conformance with ServiceMethodContext.

func (ServiceMethodCallOutputContextBase) Mutated

Mutated is required for conformance with ServiceMethodCallOutputContext.

func (ServiceMethodCallOutputContextBase) ServiceMethodErr

ServiceMethodErr is required for conformance with ServiceMethodCallOutputContext.

type ServiceMethodCallSessionError

type ServiceMethodCallSessionError interface {
	ServiceMethodCallInputContextError

	AZServiceMethodCallSessionError()
}

ServiceMethodCallSessionError is a sub-class of ServiceMethodCallInputContextError specialized for indicating error in the session.

type ServiceMethodContext

type ServiceMethodContext interface {
	ServiceContext

	AZServiceMethodContext()
}

ServiceMethodContext is an abstraction for input and output contexts used when calling a method.

type ServiceMethodError

type ServiceMethodError interface {
	ServiceError

	AZServiceMethodError()
}

ServiceMethodError is a specialization of ServiceError which focuses on method-related errors.

type ServiceMethodErrorMsg

type ServiceMethodErrorMsg struct {
	// contains filtered or unexported fields
}

ServiceMethodErrorMsg is a basic implementation of ServiceMethodError which provides an error message string.

func (ServiceMethodErrorMsg) AZServiceError

func (ServiceMethodErrorMsg) AZServiceError()

AZServiceError is required for conformance with ServiceError.

func (ServiceMethodErrorMsg) AZServiceMethodError

func (ServiceMethodErrorMsg) AZServiceMethodError()

AZServiceMethodError is required for conformance with ServiceMethodError.

func (ServiceMethodErrorMsg) Error

func (err ServiceMethodErrorMsg) Error() string

type ServiceMethodIdempotencyKey

type ServiceMethodIdempotencyKey interface {
	azob.Equatable

	AZServiceMethodIdempotencyKey()
}

ServiceMethodIdempotencyKey represents the identifier of a method call. This identifier doubles as idempotency token.

type ServiceMethodInternalError

type ServiceMethodInternalError interface {
	ServiceMethodError

	AZServiceMethodInternalError()
}

ServiceMethodInternalError represents error in the method, service, or in any dependency required to achieve the objective.

This is analogous to HTTP's 5xx status code.

type ServiceMethodInternalErrorMsg

type ServiceMethodInternalErrorMsg struct {
	// contains filtered or unexported fields
}

ServiceMethodInternalErrorMsg is a basic implementation of ServiceMethodInternalError which provides error message string.

func (ServiceMethodInternalErrorMsg) AZServiceError

func (ServiceMethodInternalErrorMsg) AZServiceError()

AZServiceError is required for conformance with ServiceError.

func (ServiceMethodInternalErrorMsg) AZServiceMethodError

func (ServiceMethodInternalErrorMsg) AZServiceMethodError()

AZServiceMethodError is required for conformance with ServiceMethodError.

func (ServiceMethodInternalErrorMsg) AZServiceMethodInternalError

func (ServiceMethodInternalErrorMsg) AZServiceMethodInternalError()

AZServiceMethodInternalError is required for conformance with ServiceMethodInternalError.

func (ServiceMethodInternalErrorMsg) Error

type ServiceMethodMessage

type ServiceMethodMessage interface {
	AZServiceMethodMessage()

	// ServiceMethodContext returns the context of this message.
	//
	// Implementations must return most specialized context implementation.
	MethodContext() ServiceMethodContext
}

ServiceMethodMessage abstracts the messages, i.e., requests and responses.

type ServiceModule

type ServiceModule interface {
	AZServiceModule()
}

ServiceModule provides an abstraction for all kind of service modules.

type ServiceMutatingMethodCallInputContext

type ServiceMutatingMethodCallInputContext[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT],
	SessionT Session[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT, SessionT],
	ServiceMethodCallInputContextT ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceMethodIdempotencyKeyT],
	ServiceMethodIdempotencyKeyT ServiceMethodIdempotencyKey,
] interface {
	ServiceMutatingMethodContext
	ServiceMethodCallInputContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceMethodIdempotencyKeyT]
}

ServiceMutatingMethodCallInputContext abstracts mutating method request contexts.

type ServiceMutatingMethodCallOutputContext

type ServiceMutatingMethodCallOutputContext interface {
	ServiceMutatingMethodContext
	ServiceMethodCallOutputContext
}

ServiceMutatingMethodCallOutputContext abstracts mutating method response contexts.

type ServiceMutatingMethodContext

type ServiceMutatingMethodContext interface {
	ServiceMethodContext
}

ServiceMutatingMethodContext abstracts contexts of mutating method requests and responses.

type ServiceMutatingMethodMessage

type ServiceMutatingMethodMessage interface {
	ServiceMethodMessage

	MutatingMethodContext() ServiceMutatingMethodContext
}

ServiceMutatingMethodMessage abstracts mutating method requests and responses.

type ServiceServer

type ServiceServer interface {
	Service
	AZServiceServer()
}

ServiceServer provides an abstraction for all service clients.

type ServiceServerConfig

type ServiceServerConfig interface {
	ServiceConfig
}

ServiceServerConfig holds the configuration for a service client.

type ServiceServerError

type ServiceServerError interface {
	ServiceError

	AZServiceServerError()
}

ServiceServerError is an abstraction for all errors emitted by a service server.

type ServiceServerModule

type ServiceServerModule struct {
	ServiceServerConfigSkeleton func() ServiceServerConfig
	NewServiceServer            func(ServiceServerConfig) (ServiceServer, ServiceServerError)
}

ServiceServerModule provides all the required to instantiate a service client.

func (ServiceServerModule) AZServiceModule

func (ServiceServerModule) AZServiceModule()

AZServiceModule is required for conformance with ServiceModule.

type Session

type Session[
	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	SessionSubjectT SessionSubject[
		TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT,
	],
	SessionT any,
] interface {
	// ID returns the identifier of this Session instance.
	ID() SessionIDT

	// DelegateSession returns the session that is a delegate of
	// this session. It returns nil if this session is not a delegated session.
	//
	// A delegation is commonly used when a service is accessing another
	// service on the behalf of a user.
	DelegateSession() *SessionT

	// ImpersonatorSession returns the session that is impersonating
	// the subject of this session, i.e., the session that was used to create
	// this session. It returns nil if this session is not an impersonation.
	ImpersonatorSession() *SessionT

	// Subject returns the subject of this session.
	Subject() SessionSubjectT

	// IsTerminal returns true if the authorized terminal is the same as termRef.
	IsTerminal(termRef TerminalIDT) bool

	// HasUserAsSubject returns true if the subject is a user instead of
	// a service application.
	HasUserAsSubject() bool

	// IsUser checks if this session is represeting a particular user.
	IsUser(userRef UserIDT) bool
}

Session represents information about a session. Every action can only be performed with an active session. A session is obtained through authorization, or authentication, of a Terminal.

TODO: scope, expiry.

type SessionID

type SessionID[IDNumT SessionIDNum] interface {
	azid.ID[IDNumT]

	// SessionIDNum returns only the ID part of this ref-key.
	SessionIDNum() IDNumT
}

SessionID is used to refer to a Session entity instance.

type SessionIDNum

type SessionIDNum interface {
	azid.IDNum

	SessionIDNumMethods
}

SessionIDNum abstracts the identifiers of Session entity instances.

type SessionIDNumMethods

type SessionIDNumMethods interface {
	AZSessionIDNum()
}

type SessionSubject

type SessionSubject[
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
] interface {
	AZSessionSubject()

	// TerminalID returns the ref-key of the terminal for this subject.
	TerminalID() TerminalIDT

	// IsRepresentingAUser returns true if this subject is representing
	// a user, i.e., the application is a user-agent, not a service application.
	//
	// If this method returns true, UserID must return a valid ref-key of
	// the user.
	IsRepresentingAUser() bool

	// UserID returns the ref-key of the user this subject represents.
	UserID() UserIDT
}

SessionSubject is an object which could be involved in an action.

type StringDisplayable

type StringDisplayable interface {
	DisplayString() string
}

StringDisplayable provides an abstraction for objects displayable as string.

type Terminal

type Terminal[
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
] interface {
	// ID returns the identifier of this Terminal instance.
	ID() TerminalIDT

	// PrincipalUser returns the ref-key of the User, if any, who authorized
	// this instance of Terminal.
	PrincipalUser() UserIDT
}

A Terminal is an object which could act within the system, i.e., an agent.

type TerminalID

type TerminalID[IDNumT TerminalIDNum] interface {
	azid.ID[IDNumT]

	// TerminalIDNum returns only the ID part of this ref-key.
	TerminalIDNum() IDNumT
}

TerminalID is used to refer to a Terminal entity instance.

type TerminalIDNum

type TerminalIDNum interface {
	azid.IDNum

	TerminalIDNumMethods
}

TerminalIDNum abstracts the identifiers of Terminal entity instances.

type TerminalIDNumMethods

type TerminalIDNumMethods interface {
	AZTerminalIDNum()
}

type UserID

type UserID[IDNumT UserIDNum] interface {
	azid.ID[IDNumT]

	// UserIDNum returns only the ID part of this ref-key.
	UserIDNum() IDNumT
}

UserID is used to refer to a User entity instance.

type UserIDNum

type UserIDNum interface {
	azid.IDNum

	UserIDNumMethods
}

UserID abstracts the identifiers of User entity instances.

type UserIDNumMethods

type UserIDNumMethods interface {
	AZUserIDNum()
}

type ValueObject

type ValueObject interface {
}

A ValueObject is a small object that represents a simple entity whose equality is not based on identity, i.e., two value objects are equal when they have the same value, not necessarily being the same object.

type ValueObjectAssert

type ValueObjectAssert[T any] interface {
	azob.CloneableAssert[T]
}

ValueObjectAssert is tool to assert that a struct conforms the characteristic of a value-object.

To use:

var _ = ValueObjectAssert[MyStruct] = MyStruct{}

Jump to

Keyboard shortcuts

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