messageflow

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package messageflow provides tools for visualizing AsyncAPI specifications. It enables parsing AsyncAPI documents and transforming them into visual format to help understand message flows and service interactions.

Index

Constants

View Source
const (
	FormatModeContextServices = FormatMode("context_services")
	FormatModeServiceChannels = FormatMode("service_channels")
	FormatModeChannelServices = FormatMode("channel_services")
	FormatModeServiceServices = FormatMode("service_services")
)

Variables

This section is empty.

Functions

func NewUnsupportedFormatError

func NewUnsupportedFormatError(given, expected TargetType) error

NewUnsupportedFormatError creates a new UnsupportedFormatError.

func NewUnsupportedFormatModeError

func NewUnsupportedFormatModeError(given FormatMode, expected []FormatMode) error

NewUnsupportedFormatModeError creates a new UnsupportedFormatModeError.

Types

type Action

type Action string

Action represents the type of operation that can be performed on a channel.

const (
	ActionSend    Action = "send"
	ActionReceive Action = "receive"
)

type Change

type Change struct {
	Type      ChangeType `json:"type"`
	Category  string     `json:"category"`
	Name      string     `json:"name"`
	Details   string     `json:"details,omitempty"`
	Diff      string     `json:"diff,omitempty"`
	Timestamp time.Time  `json:"timestamp"`
}

Change represents a single change in the schema.

type ChangeType

type ChangeType string

ChangeType represents the type of change that occurred.

const (
	ChangeTypeAdded   ChangeType = "added"
	ChangeTypeRemoved ChangeType = "removed"
	ChangeTypeChanged ChangeType = "changed"
)

type Changelog

type Changelog struct {
	Date    time.Time `json:"date"`
	Changes []Change  `json:"changes"`
}

Changelog represents a collection of changes with a version and date.

func CompareSchemas

func CompareSchemas(oldSchema, newSchema Schema) Changelog

CompareSchemas compares two schemas and returns a changelog of differences.

type Channel

type Channel struct {
	Name    string  `json:"name"`
	Message Message `json:"message"`
}

Channel represents a communication channel with a name and message.

type FormatMode

type FormatMode string

FormatMode represents the mode of format for schema.

type FormatOptions

type FormatOptions struct {
	Mode         FormatMode
	Service      string
	Channel      string
	OmitPayloads bool
}

type FormattedSchema

type FormattedSchema struct {
	Type TargetType `json:"type"`
	Data []byte     `json:"data"`
}

FormattedSchema represents a schema that has been formatted for a specific target type.

type Message

type Message struct {
	Name    string `json:"name"`
	Payload string `json:"payload"`
}

Message represents a message with a name and payload.

type Operation

type Operation struct {
	Action  Action   `json:"action"`
	Channel Channel  `json:"channel"`
	Reply   *Channel `json:"reply,omitempty"`
}

Operation defines an action to be performed on a channel, optionally with a reply channel.

type Schema

type Schema struct {
	Services []Service `json:"services"`
}

Schema defines the structure of a message flow schema containing services and their operations.

func MergeSchemas

func MergeSchemas(schemas ...Schema) Schema

MergeSchemas combines multiple Schema objects into a single Schema.

func (*Schema) Sort

func (s *Schema) Sort()

Sort sorts the services and their operations in a consistent order.

type SchemaExtractor

type SchemaExtractor interface {
	ExtractSchema(ctx context.Context) (Schema, error)
}

SchemaExtractor interface defines the contract for extracting schemas.

type SchemaFormatter

type SchemaFormatter interface {
	FormatSchema(ctx context.Context, s Schema, opts FormatOptions) (FormattedSchema, error)
}

SchemaFormatter interface defines the contract for formatting schemas.

type SchemaRenderer

type SchemaRenderer interface {
	RenderSchema(ctx context.Context, fs FormattedSchema) ([]byte, error)
}

SchemaRenderer interface defines the contract for rendering formatted schemas.

type Service

type Service struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	Operation   []Operation `json:"operations"`
}

Service represents a service in the message flow with its name and operations.

type Source

type Source interface {
	SchemaExtractor
}

Source interface defines the contract for schema extraction.

type Target

type Target interface {
	SchemaFormatter
	SchemaRenderer
	Capabilities() TargetCapabilities
}

Target interface defines the contract for schema formatting and rendering.

type TargetCapabilities

type TargetCapabilities struct {
	Format bool
	Render bool
}

TargetCapabilities represents the capabilities of a Target implementation.

type TargetType

type TargetType string

TargetType represents the type of target format for schema conversion.

type UnsupportedFormatError

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

UnsupportedFormatError represents an error when an unsupported format is provided.

func (*UnsupportedFormatError) Error

func (err *UnsupportedFormatError) Error() string

Error implements the error interface for UnsupportedFormatError.

type UnsupportedFormatModeError

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

UnsupportedFormatModeError represents an error when an unsupported format mode is provided.

func (*UnsupportedFormatModeError) Error

func (err *UnsupportedFormatModeError) Error() string

Error implements the error interface for UnsupportedFormatError.

Jump to

Keyboard shortcuts

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