Help us shape the future of Go! Take the 2026 Go Developer Survey

eventmodeling

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package eventmodeling parses Mermaid's event modeling diagrams and lays them out, as Pele's src/diagrams/eventmodeling does: a tokenizer and a parser that read what Mermaid's Langium grammar reads, buildEventModel, which sorts the frames into lanes and finds what feeds each, and Layout, which lays the lanes out across, with time running left to right, or the frames down as cards in a narrow host.

Index

Constants

View Source
const (
	RoleLane          scene.Role = "eventmodeling.lane"
	RoleLaneLabel     scene.Role = "eventmodeling.lane-label"
	RoleRelation      scene.Role = "eventmodeling.relation"
	RoleData          scene.Role = "eventmodeling.data"
	RoleFrameID       scene.Role = "eventmodeling.frame-id"
	RoleNote          scene.Role = "eventmodeling.note"
	RoleNoteText      scene.Role = "eventmodeling.note-text"
	RoleSpecification scene.Role = "eventmodeling.specification"
	RoleSpecText      scene.Role = "eventmodeling.specification-text"
	RoleTitle         scene.Role = "eventmodeling.title"
)

The scene's roles. A frame is a node of the role of its kind, "eventmodeling.command" and the rest, its name its label, with the tag "reset" for a reset frame; its example data is a text item after it. Across, a lane is a group, with its label; down, each frame's lane is named by a text item before it, and its number by one after it. A note and a specification are nodes, their heading the label, their lines a text item after each.

Variables

This section is empty.

Functions

func Layout

func Layout(m *Model, config diagram.Config, o *layout.Options) *scene.Scene

Layout lays an event modeling diagram out as a scene, as Pele's renderEventModel does: across, in a lane for each group of kinds and namespace, or, when the host is narrow, down, a card to a frame. The diagram has no configuration of its own.

Types

type Box

type Box struct {
	ID        string // the frame number as written, as "01"
	Kind      Kind
	Entity    string
	Name      string
	Namespace string // "" for none
	Reset     bool
	Lane      *Lane
	// Data is the example data of the frame or of the data block it refers to, if HasData.
	Data     string
	HasData  bool
	DataType string // "" for none
}

Box is a frame, Pele's EmBox.

type Group

type Group string

Group is the group of lanes a kind of entity is drawn in, Pele's LaneGroup: "trigger" for screens and processors, "state" for commands and read models, "stream" for events.

type Kind

type Kind string

Kind is the kind of entity a frame shows, Pele's EntityKind: "ui", "processor", "command", "readmodel" or "event".

type Lane

type Lane struct {
	// Index orders the lanes, as Mermaid's key does: 0 for UI/Automation, 100 for
	// Command/Read Model, 200 for Events, and the next free number after those for each
	// namespace.
	Index     int
	Label     string
	Group     Group
	Namespace string // "" for none
}

Lane is a swimlane, Pele's EmLane.

type Model

type Model struct {
	Title, AccTitle, AccDescr string
	Boxes                     []*Box
	// Lanes are sorted from top to bottom.
	Lanes          []*Lane
	Relations      []Relation
	Notes          []Note
	Specifications []Specification
	Entities       []string
}

Model is a parsed event modeling diagram, Pele's EventModelingModel. A string Pele leaves undefined is empty.

func Parse

func Parse(source, title string) (*Model, error)

Parse parses an event modeling diagram's text, as the parse of Pele's eventmodeling diagram does: source is what diagram.Prepared.Source gives with its comments kept, and title the title its front matter gives, "" for none. An error is a *diagram.Error.

func ParsePrepared

func ParsePrepared(p *diagram.Prepared) (*Model, error)

ParsePrepared parses a prepared event modeling diagram. Its comment lines are kept, as Pele keeps them, for a data block to show them.

type Note

type Note struct {
	Frame, Text string
	DataType    string // "" for none
}

Note is a note on a frame, Pele's EmNote.

type Relation

type Relation struct {
	Source, Target *Box
}

Relation is a frame that feeds another, Pele's EmRelation.

type Specification

type Specification struct {
	Frame             string
	Given, When, Then []string
}

Specification is a given, when, then specification of a frame, Pele's EmSpecification.

Jump to

Keyboard shortcuts

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