service

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package service is the service tier: a Base, built from the service's contract, is the embeddable core of a consumer's service, running its custom operations through the tier's decoration (Tier) with the promoted Exec. An Entity (entity.go) is a Base that also serves an entity's roles over its repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tier added in v0.0.7

func Tier() decorate.Tier

Tier is the service tier's decoration: recovery → tracing → metrics → logging → authorization → timeout, outermost first.

Types

type Base added in v0.0.7

type Base struct {
	decorate.Subject
}

Base is the embeddable core of a service named by its Subject: Name and Exec run a domain operation through the tier's decoration. Each operation is a method of the service's contract, decorated under its own name. The zero Base runs operations undecorated.

func NewBase added in v0.0.7

func NewBase[S any](decs decorate.Decorations, name string) (Base, error)

NewBase builds the Base for the service named name whose operations are the methods of its contract S (an interface), decorated from decs: the service as the service-tier component name, and each operation op as name+"."+op. A contract that is not an interface, or a decoration that fails to resolve, is an error.

type Entity added in v0.0.16

type Entity[T, P any, ID comparable, N any] struct {
	// Entity serves the roles.
	decorate.Entity[T, P, ID]

	// Base runs the service's operations and supplies Name and Exec.
	Base
	// contains filtered or unexported fields
}

Entity is the service-tier entity base: a Base that also serves the entity's roles over N, the next tier's contract (a repository), checking each entity Create, Update and Upsert write with the service's validator. A service embeds it and adds its domain operations through Exec, calling Next; an override of a role calls Next, never the role it shadows.

func NewEntity added in v0.0.16

func NewEntity[S, T, P any, ID comparable, N any](
	decs decorate.Decorations,
	name string,
	next N,
	validate func(*T) error,
) (Entity[T, P, ID, N], error)

NewEntity builds the Entity of the service named name over next, whose contract is S (an interface), serving the roles S has from next's methods and rejecting a written entity validate refuses (nil accepts every entity): decorated as NewBase decorates. A role S names that next lacks is CodeInternal.

func (Entity[T, P, ID, N]) Next added in v0.0.16

func (e Entity[T, P, ID, N]) Next() N

Next returns the repository the service is built over, as its contract declares it.

Jump to

Keyboard shortcuts

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