azcore

package
v2.0.0-...-6da97b0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 6 Imported by: 3

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 ErrServiceOpNotImplemented = &ServiceOpInternalErrorMsg{msg: "not implemented"}

ErrServiceOpNotImplemented 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 {
}

Adjunct abstracts adjuncts.

type AdjunctEntityAttrSet

type AdjunctEntityAttrSet interface {
	AttrSet
}

AdjunctEntityAttrSet abstracts adjunct entity attributes.

type AdjunctEntityID

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

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 {
}

type AdjunctEntityService

type AdjunctEntityService interface {
	Service
}

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.

type AdjunctEntityServiceClient

type AdjunctEntityServiceClient interface {
	AdjunctEntityService
	ServiceClient
}

AdjunctEntityServiceClient abstracts adjunct entity service client implementations.

type AdjunctEntityServiceClientBase

type AdjunctEntityServiceClientBase struct {
	AdjunctEntityServiceBase
}

AdjunctEntityServiceClientBase provides a base for AdjunctEntityServiceClient implementations.

type AdjunctEntityServiceServer

type AdjunctEntityServiceServer interface {
	AdjunctEntityService
	ServiceServer
}

AdjunctEntityServiceServer abstracts adjunct entity service client implementations.

type AdjunctEntityServiceServerBase

type AdjunctEntityServiceServerBase struct {
	AdjunctEntityServiceBase
}

AdjunctEntityServiceServerBase provides a base for AdjunctEntityServiceServer implementations.

type AttrSet

type AttrSet interface {
}

AttrSet abstracts attributes.

type Context

type Context interface {
	context.Context
}

Context is a generalized context for all service methods.

type EntityAttrSet

type EntityAttrSet interface {
	AttrSet
}

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

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

type EntityCreationCallContext

type EntityCreationCallContext[
	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],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
] interface {
	ServiceOpCallContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceOpIdempotencyKeyT]
}

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

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],
	EntityCreationInfoT EntityCreationInfo[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT],
] interface {
	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],
] interface {
	OperationInfo[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT]
}

EntityCreationInfo holds information about the creation of an entity.

type EntityCreationOutput

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

type EntityCreationResultContext

type EntityCreationResultContext interface {
	ServiceOpResultContext
}

EntityCreationResultContext 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
}

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.

type EntityID

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

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 {
}

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 EntityMutatingMessage

type EntityMutatingMessage interface {
	EntityOpMessage
	ServiceMutationOpMessage

	EntityMutatingContext() EntityMutationOpContext
}

EntityMutatingMessage abstracts entity mutating method requests and responses.

type EntityMutatingOpCallContext

type EntityMutatingOpCallContext[
	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],
	ServiceOpCallContextT ServiceOpCallContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceOpIdempotencyKeyT],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
] interface {
	EntityMutationOpContext
	EntityOpCallContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceOpIdempotencyKeyT]
	ServiceMutationOpCallContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceOpCallContextT, ServiceOpIdempotencyKeyT]
}

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

type EntityMutatingOpResultContext

type EntityMutatingOpResultContext interface {
	EntityMutationOpContext
	EntityOpResultContext
	ServiceMutationOpResultContext
}

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

type EntityMutationOpContext

type EntityMutationOpContext interface {
	EntityOpContext
	ServiceMutationOpContext
}

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

type EntityOpCallContext

type EntityOpCallContext[
	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],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
] interface {
	EntityOpContext
	ServiceOpCallContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceOpIdempotencyKeyT,
	]
}

EntityOpCallContext is an abstraction for all method call input contexts.

type EntityOpContext

type EntityOpContext interface {
	ServiceOpContext
}

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

type EntityOpMessage

type EntityOpMessage interface {
	ServiceOpMessage

	EntityOpContext() EntityOpContext
}

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

type EntityOpResultContext

type EntityOpResultContext interface {
	EntityOpContext
	ServiceOpResultContext
}

EntityOpResultContext is an abstraction for all method call output contexts.

type EntityRevisionNumber

type EntityRevisionNumber interface {
	int16 | int32 | int64
}

type EntityService

type EntityService interface {
}

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.

type EntityServiceClient

type EntityServiceClient interface {
	EntityService
}

EntityServiceClient provides an abstraction for all entity service clients.

type EntityServiceServer

type EntityServiceServer interface {
	EntityService
}

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 {
}

Event provides a contract for all events in the system.

type EventBase

type EventBase struct{}

EventBase provides a common implementation for all events.

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 KeyedEntityAttrSet

type KeyedEntityAttrSet[
	EntityIDNumT EntityIDNum,
	EntityIDT EntityID[EntityIDNumT],
	EntityAttrSetT EntityAttrSet,
] struct {
	ID      EntityIDT
	AttrSet EntityAttrSetT
}

KeyedEntityAttrSet 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],
] 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],
] interface {
	// IdempotencyKey returns the idempotency key for this operation.
	IdempotencyKey() ServiceOpIdempotencyKey

	// 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 Service

type Service interface {
}

Service provides an abstraction for all services.

type ServiceClient

type ServiceClient interface {
	Service
}

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
}

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.

type ServiceConfig

type ServiceConfig interface {
}

ServiceConfig provides an abstractions for all service-related configs.

type ServiceContext

type ServiceContext interface {
}

ServiceContext provides an abstraction for all service-related contexts.

type ServiceError

type ServiceError interface {
	Error
}

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

type ServiceModule

type ServiceModule interface {
}

ServiceModule provides an abstraction for modular services.

type ServiceMutationOpCallContext

type ServiceMutationOpCallContext[
	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],
	ServiceOpCallContextT ServiceOpCallContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceOpIdempotencyKeyT],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
] interface {
	ServiceMutationOpContext
	ServiceOpCallContext[
		SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT,
		SessionSubjectT,
		SessionT, ServiceOpIdempotencyKeyT]
}

ServiceMutationOpCallContext abstracts mutating method request contexts.

type ServiceMutationOpContext

type ServiceMutationOpContext interface {
	ServiceOpContext
}

ServiceMutationOpContext abstracts contexts of mutating method requests and responses.

type ServiceMutationOpMessage

type ServiceMutationOpMessage interface {
	ServiceOpMessage

	MutationOpContext() ServiceMutationOpContext
}

ServiceMutationOpMessage abstracts mutating method requests and responses.

type ServiceMutationOpResultContext

type ServiceMutationOpResultContext interface {
	ServiceMutationOpContext
	ServiceOpResultContext
}

ServiceMutationOpResultContext abstracts mutating method response contexts.

type ServiceOpCallContext

type ServiceOpCallContext[
	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],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
] interface {
	ServiceOpContext

	// 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() ServiceOpIdempotencyKeyT

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

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

type ServiceOpCallContextError

type ServiceOpCallContextError interface {
	ServiceOpCallInvocationError
}

ServiceOpCallContextError provides information for request-context-related error. It is a sub-class of ServiceOpCallInputError.

type ServiceOpCallData

type ServiceOpCallData interface {
}

ServiceOpCallData abstracts method request body.

type ServiceOpCallInput

type ServiceOpCallInput[
	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],
	ServiceOpIdempotencyKeyT ServiceOpIdempotencyKey,
	ContextT ServiceOpCallContext[
		SessionIDNumT, SessionIDT, TerminalIDNumT, TerminalIDT,
		UserIDNumT, UserIDT, SessionSubjectT, SessionT,
		ServiceOpIdempotencyKeyT],
	DataT ServiceOpCallData,
] struct {
	Context ContextT
	Data    DataT
}

type ServiceOpCallInputMetadata

type ServiceOpCallInputMetadata interface {
}

type ServiceOpCallInvocationError

type ServiceOpCallInvocationError interface {
	ServiceOpError
}

ServiceOpCallInvocationError is a sub-class of ServiceOpError 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 ServiceOpCallOriginInfo

type ServiceOpCallOriginInfo 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
}

ServiceOpCallOriginInfo holds information about a call's origin.

TODO: key-value custom data

type ServiceOpCallSessionError

type ServiceOpCallSessionError interface {
	ServiceOpCallContextError
}

ServiceOpCallSessionError is a sub-class of ServiceOpCallContextError specialized for indicating error in the session.

type ServiceOpContext

type ServiceOpContext interface {
	ServiceContext

	// OperationName 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`.
	OperationName() 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
}

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

type ServiceOpError

type ServiceOpError interface {
	ServiceError
}

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

type ServiceOpErrorMsg

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

ServiceOpErrorMsg is a basic implementation of ServiceOpError which provides an error message string.

func (ServiceOpErrorMsg) Error

func (err ServiceOpErrorMsg) Error() string

type ServiceOpIdempotencyKey

type ServiceOpIdempotencyKey interface {
	azob.Equatable
}

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

type ServiceOpInternalError

type ServiceOpInternalError interface {
	ServiceOpError
}

ServiceOpInternalError 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 ServiceOpInternalErrorMsg

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

ServiceOpInternalErrorMsg is a basic implementation of ServiceOpInternalError which provides error message string.

func (ServiceOpInternalErrorMsg) Error

func (err ServiceOpInternalErrorMsg) Error() string

type ServiceOpMessage

type ServiceOpMessage interface {
	// ServiceOpContext returns the context of this message.
	//
	// Implementations must return most specialized context implementation.
	ServiceOpContext() ServiceOpContext
}

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

type ServiceOpResultContext

type ServiceOpResultContext interface {
	//TODO: ServiceOpCallContext, or keep it like this and
	// add a method to access the input context: OpCallContext()
	ServiceOpContext

	// Returns the error, if any.
	ServiceOpErr() ServiceOpError

	// 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
}

ServiceOpResultContext 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 ServiceOpResultContextBase

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

ServiceOpResultContextBase is a base for ServiceOpResultContext implementations.

func NewOpResultContext

func NewOpResultContext(
	opName string,
	resourceID string,
	err ServiceOpError,
	mutated bool,
) ServiceOpResultContextBase

NewOpResultContext creates a new instance of ServiceOpResultContext.

func (ServiceOpResultContextBase) Mutated

func (ctx ServiceOpResultContextBase) Mutated() bool

Mutated is required for conformance with ServiceOpResultContext.

func (ServiceOpResultContextBase) OperationName

func (ctx ServiceOpResultContextBase) OperationName() string

OperationName is required for conformance with ServiceOpContext.

func (ServiceOpResultContextBase) ResourceID

func (ctx ServiceOpResultContextBase) ResourceID() string

ResourceID is required for conformance with ServiceOpContext.

func (ServiceOpResultContextBase) ServiceOpErr

func (ctx ServiceOpResultContextBase) ServiceOpErr() ServiceOpError

ServiceOpErr is required for conformance with ServiceOpResultContext.

type ServiceServer

type ServiceServer interface {
	Service
}

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
}

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.

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,
	],
] 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.
	//
	//     User --> Service A --> Service B
	//
	// In this example, the user is delegating Service A to accces their
	// data in Service B. As seen by Service B, the subject of the Session
	// is the delegating user and this method will return the Session of
	// Service A.
	DelegateSession() Session[SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT, SessionSubjectT]

	// 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.
	//
	//     User A (Admin) --> (User B) --> Service
	//
	// In this example, User A, who is an admin, impersonate User B to access
	// the Service. The subject of the Session as seen by the Service is
	// User B and this method will return the Session of User A.
	ImpersonatorSession() Session[SessionIDNumT, SessionIDT,
		TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT, SessionSubjectT]

	// 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 representing 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 {
}

type SessionSubject

type SessionSubject[
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
] interface {
	// 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 {
}

type TerminalRef

type TerminalRef[
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	TerminalT Terminal[TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT],
] struct {
	// contains filtered or unexported fields
}

func NewTerminalRef

func NewTerminalRef[
	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
	TerminalT Terminal[TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT],
](
	id TerminalIDT,
	instanceResolver func(context.Context, TerminalIDT) (TerminalT, error),
) TerminalRef[TerminalIDNumT, TerminalIDT, UserIDNumT, UserIDT, TerminalT]

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 {
}

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