archsketch

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package archsketch is a release's architecture snapshot (ADR-0471): what a process application offers to its environment and what it depends on, taken by value when the release is recorded, and the renderings a reader takes away from it — a deterministic SVG and an ArchiMate Open Exchange document.

The package holds no state and reads nothing. The server assembles a Snapshot from the compiled processes a release shipped, on its run loop, and stores it on the release record in the same write that records the release; the renderers turn a stored snapshot into bytes and never consult anything else. That is what makes a rendering of v7 the same picture tomorrow as today: nothing it is drawn from can change after the release was recorded.

A snapshot holds the release's **logical part** — the part fixed by its content, identical on every installation that records it — and, from format version 2, the recording installation's **physical part**: which worker serves each name there, at which endpoint, and who opens which connection (ADR-0471 §1; see physical.go). A snapshot from before that has no physical part, and its renderings say so rather than drawing a guess.

Index

Constants

View Source
const (
	// PlacementEngine: the Atlas server runs the Worker Type itself and connects to the
	// target directly. Deprecated for side-effecting work (ADR-0164), and still how
	// some installations run.
	PlacementEngine = "engine"
	// PlacementWorker: a worker process leases the work from Atlas's API and connects
	// to the target — two connections, opened from the worker's side both times.
	PlacementWorker = "worker"
)

Placements: who opens the connection to a worker's target system.

View Source
const (
	// DependencyWorker is a worker named in the model: work the engine hands to
	// whatever serves that name.
	DependencyWorker = "worker"
	// DependencyRuntimeWorker is a worker name authored as a FEEL expression. Which
	// worker it reaches is decided per instance, so the snapshot holds the expression
	// and nothing it could resolve to.
	DependencyRuntimeWorker = "runtimeWorker"
	// DependencyJobType is a service or send task's job type: work any worker that
	// subscribes to the type leases from Atlas's API (ADR-0007). The model names the
	// work, not who does it.
	DependencyJobType = "jobType"
	// DependencyCall is a call activity into a process this release did not ship.
	DependencyCall = "call"
	// DependencyDecision is a local DMN decision a business rule task evaluates. It
	// runs inside the engine and crosses no boundary, so it is recorded for
	// completeness and drawn inside the application rather than beside it.
	DependencyDecision = "decision"
)

Dependency kinds.

View Source
const (
	// EntryMessage is a message name the application receives: published to the
	// server under that name, it reaches the elements that wait for it.
	EntryMessage = "message"
)

Entry point kinds.

View Source
const FormatVersion = 3

FormatVersion versions the shape of a stored Snapshot. It is written into every snapshot, so a reader can tell which fields a snapshot from an older build can be expected to carry. A snapshot is never rewritten when this changes.

Version 2 added the physical part and job-type dependencies; version 3 the endpoints worker instances report for the names they serve.

View Source
const MappingVersion = 3

MappingVersion versions how a snapshot is drawn and written as ArchiMate: which facts become which elements and relationships. It is a small public contract — a document generated under one version stays what it was — and every rendering states it. Version 2 draws the physical part: connections from the side that opens them, target systems, and job types. Version 3 draws a reported endpoint as reported.

A snapshot keeps the version it was taken under, and a snapshot without a physical part is drawn exactly as version 1 drew it, so the version a rendering states is the snapshot's own.

Variables

This section is empty.

Functions

func ArchiMate

func ArchiMate(s Snapshot, m Meta) []byte

ArchiMate renders the snapshot as an ArchiMate Model Exchange document.

func SVG

func SVG(s Snapshot, m Meta) []byte

SVG renders the snapshot as a standalone SVG document.

Types

type Dependency

type Dependency struct {
	Kind string `json:"kind"`
	// Name is the worker name, the FEEL expression of a runtime worker, the job type,
	// the called process id, or the decision id.
	Name string `json:"name"`
	// WorkerType is a worker's Worker Type ("rest", "mail", …) as the model's task
	// type states it.
	WorkerType string `json:"workerType,omitempty"`
	// TargetApplicationID and TargetApplication name the application that held the
	// called process on the recording installation when the snapshot was taken. Empty
	// when nothing there held it — which says the call had no target there, not that
	// it has none anywhere.
	TargetApplicationID string `json:"targetApplicationId,omitempty"`
	TargetApplication   string `json:"targetApplication,omitempty"`
	UsedBy              []Use  `json:"usedBy"`
}

Dependency is one way out.

type Endpoint

type Endpoint struct {
	Scheme string `json:"scheme,omitempty"`
	Host   string `json:"host,omitempty"`
	// Port is the port the configured value named. Empty when it named none, which
	// means the scheme's or the Worker Type's default — the snapshot does not guess
	// which.
	Port string `json:"port,omitempty"`
	// Unparseable is set when the configured value could not be read as an address.
	// The value itself is not kept: what cannot be parsed cannot be cleaned either.
	Unparseable bool `json:"unparseable,omitempty"`
	// Withheld is set on a read for a reader who may not see it. Never stored.
	Withheld bool `json:"withheld,omitempty"`
}

Endpoint is one address, reduced to the three parts a reader of an architecture sketch needs.

func ParseEndpoint

func ParseEndpoint(raw string) *Endpoint

ParseEndpoint reduces a configured endpoint to scheme, host and port (internal/endpoint), and returns nil for an empty value. A value that cannot be an address is recorded as unparseable and not kept.

func (Endpoint) String

func (e Endpoint) String() string

String renders the endpoint as a reader writes an address.

type EntryPoint

type EntryPoint struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
	// Starts is set when at least one element receiving this message starts an
	// instance; otherwise every receipt continues one that is already running.
	Starts bool  `json:"starts,omitempty"`
	UsedBy []Use `json:"usedBy"`
}

EntryPoint is one way in.

type JobTypeSite

type JobTypeSite struct {
	JobType string `json:"jobType"`
	Observers
}

JobTypeSite is what the installation had seen serve one job type.

type Meta

type Meta struct {
	ApplicationID string
	Application   string
	ReleaseID     string
	Version       int32
}

Meta is what a rendering says about the release it was drawn from. It comes from the release record and the application, not from the snapshot, because the snapshot is the release's content and these are its names.

type Observers

type Observers struct {
	ObservedBy        []string `json:"observedBy,omitempty"`
	Observed          int      `json:"observed"`
	ObserversWithheld bool     `json:"observersWithheld,omitempty"`
}

Observers are the worker instances that reported serving something since the installation started. Observed is their number, kept beside the ids so a read that withholds the ids still says how many there were.

type Physical

type Physical struct {
	// Node and Environment are the recording installation's operator-given name and
	// environment (ADR-0189 §6). Empty where nobody named them.
	Node        string `json:"node,omitempty"`
	Environment string `json:"environment,omitempty"`
	// ExternalURL is the origin the installation was configured to be reached under.
	// Nil when none was configured: the listen address is not the reachable address,
	// so it is not offered in its place.
	ExternalURL *Endpoint `json:"externalUrl,omitempty"`
	// PublicStartLinks counts the public start links each process had here. The links
	// themselves are their own authorization and are never recorded.
	PublicStartLinks []StartLinks  `json:"publicStartLinks"`
	Workers          []WorkerSite  `json:"workers"`
	JobTypes         []JobTypeSite `json:"jobTypes"`
}

Physical is the installation's half of a snapshot.

func (Physical) Redacted

func (p Physical) Redacted(mayViewWorker func(configuredID string) bool, mayViewInstances bool) Physical

Redacted is the physical part as one reader may see it. mayViewWorker answers for a configured worker's endpoint by the worker's id; mayViewInstances answers for the worker instances, which are what the Workers view shows. The receiver is not changed.

type Process

type Process struct {
	ProcessID string `json:"processId"`
	Name      string `json:"name,omitempty"`
	Version   int32  `json:"version"`
	// Unread is set when the definition was recorded as a member but its compiled
	// form was not there to read. Its entry points and dependencies are then missing
	// from the snapshot, and the snapshot says so rather than drawing a process that
	// offers and needs nothing.
	Unread bool `json:"unread,omitempty"`
}

Process is one process the release shipped.

type Snapshot

type Snapshot struct {
	FormatVersion  int `json:"formatVersion"`
	MappingVersion int `json:"mappingVersion"`
	// TakenAt is when the snapshot was taken, by the server's clock, in Unix seconds.
	TakenAt int64 `json:"takenAt"`
	// Processes are the release's process members, as they were deployed.
	Processes []Process `json:"processes"`
	// EntryPoints are where the environment reaches into the application.
	EntryPoints []EntryPoint `json:"entryPoints"`
	// Dependencies are what the application reaches out to.
	Dependencies []Dependency `json:"dependencies"`
	// Physical is the recording installation's half, absent on a snapshot taken
	// before format version 2.
	Physical *Physical `json:"physical,omitempty"`
}

Snapshot is the logical part of one release's architecture.

func (Snapshot) LocalDecisions

func (s Snapshot) LocalDecisions() int

LocalDecisions counts the distinct local decisions the application evaluates.

func (*Snapshot) Normalize

func (s *Snapshot) Normalize()

Normalize puts every list in a fixed order and merges duplicates, so the same release produces the same snapshot — and the same rendering bytes — whatever order its members were read in.

func (Snapshot) NotShown

func (s Snapshot) NotShown() []string

NotShown is what a rendering of this snapshot lists as absent, in this order. A sketch is believed for everything it does not contradict, so the gaps travel inside it.

func (Snapshot) Outbound

func (s Snapshot) Outbound() []Dependency

Outbound is the dependencies that cross the server's boundary — everything but the local decisions, which the engine evaluates itself.

func (Snapshot) UnreadProcesses

func (s Snapshot) UnreadProcesses() int

UnreadProcesses counts the members whose compiled form was not there to read.

type StartLinks struct {
	ProcessID string `json:"processId"`
	Links     int    `json:"links"`
}

StartLinks is how many public start links one process had.

type Use

type Use struct {
	ProcessID string `json:"processId"`
	ElementID string `json:"elementId,omitempty"`
}

Use is one element that states an entry point or a dependency: what a line on the sketch can be traced back to.

type WorkerSite

type WorkerSite struct {
	Name       string `json:"name"`
	WorkerType string `json:"workerType,omitempty"`
	Placement  string `json:"placement"`
	// ConfiguredID is the configured worker the installation held under this name, and
	// empty when it held none — the case of a worker that keeps its own configuration
	// (ADR-0168). Kept so a read can ask who may see its endpoint.
	ConfiguredID    string    `json:"configuredId,omitempty"`
	Endpoint        *Endpoint `json:"endpoint,omitempty"`
	MailboxEndpoint *Endpoint `json:"mailboxEndpoint,omitempty"`
	// EndpointReported is set when Endpoint is not the installation's configuration
	// but what the worker instances serving the name reported (format version 3).
	// It is then information about those instances, and a read treats it as such.
	EndpointReported bool `json:"endpointReported,omitempty"`
	// EndpointsDiffer is set when the instances serving the name reported different
	// endpoints. None of them is recorded then: picking one would draw a single
	// system where the installation reaches several.
	EndpointsDiffer bool `json:"endpointsDiffer,omitempty"`
	Observers
}

WorkerSite is what the installation had in place for one worker name.

Jump to

Keyboard shortcuts

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