Documentation ¶
Overview ¶
Package message provides utilities for representing information about Dogma messages and their use within an application.
Index ¶
- Variables
- func IsEqualSetN(a, b NameCollection) bool
- func IsEqualSetT(a, b TypeCollection) bool
- func IsIntersectingN(a, b NameCollection) bool
- func IsIntersectingT(a, b TypeCollection) bool
- func IsSubsetN(sub, sup NameCollection) bool
- func IsSubsetT(sub, sup TypeCollection) bool
- type Name
- type NameCollection
- type NameRoles
- func (nr NameRoles) Add(n Name, r Role) bool
- func (nr NameRoles) AddM(m dogma.Message, r Role) bool
- func (nr NameRoles) FilterByRole(r Role) NameRoles
- func (nr NameRoles) Has(n Name) bool
- func (nr NameRoles) HasM(m dogma.Message) bool
- func (nr NameRoles) IsEqual(o NameRoles) bool
- func (nr NameRoles) Len() int
- func (nr NameRoles) Range(fn func(Name) bool) bool
- func (nr NameRoles) RangeByRole(r Role, fn func(Name) bool) bool
- func (nr NameRoles) Remove(n Name) bool
- func (nr NameRoles) RemoveM(m dogma.Message) bool
- type NameSet
- func (s NameSet) Add(n Name) bool
- func (s NameSet) AddM(m dogma.Message) bool
- func (s NameSet) Has(n Name) bool
- func (s NameSet) HasM(m dogma.Message) bool
- func (s NameSet) IsEqual(o NameSet) bool
- func (s NameSet) Len() int
- func (s NameSet) Range(fn func(Name) bool) bool
- func (s NameSet) Remove(n Name) bool
- func (s NameSet) RemoveM(m dogma.Message) bool
- type Role
- func (r Role) Is(roles ...Role) bool
- func (r Role) Marker() string
- func (r Role) MarshalBinary() ([]byte, error)
- func (r Role) MarshalText() ([]byte, error)
- func (r Role) MustBe(roles ...Role)
- func (r Role) MustNotBe(roles ...Role)
- func (r Role) MustValidate()
- func (r Role) ShortString() string
- func (r Role) String() string
- func (r *Role) UnmarshalBinary(data []byte) error
- func (r *Role) UnmarshalText(text []byte) error
- func (r Role) Validate() error
- type Type
- type TypeCollection
- type TypeRoles
- func (tr TypeRoles) Add(t Type, r Role) bool
- func (tr TypeRoles) AddM(m dogma.Message, r Role) bool
- func (tr TypeRoles) FilterByRole(r Role) TypeRoles
- func (tr TypeRoles) Has(t Type) bool
- func (tr TypeRoles) HasM(m dogma.Message) bool
- func (tr TypeRoles) IsEqual(o TypeRoles) bool
- func (tr TypeRoles) Len() int
- func (tr TypeRoles) Range(fn func(Type) bool) bool
- func (tr TypeRoles) RangeByRole(r Role, fn func(Type) bool) bool
- func (tr TypeRoles) Remove(t Type) bool
- func (tr TypeRoles) RemoveM(m dogma.Message) bool
- type TypeSet
- func (s TypeSet) Add(t Type) bool
- func (s TypeSet) AddM(m dogma.Message) bool
- func (s TypeSet) Has(t Type) bool
- func (s TypeSet) HasM(m dogma.Message) bool
- func (s TypeSet) IsEqual(o TypeSet) bool
- func (s TypeSet) Len() int
- func (s TypeSet) Range(fn func(Type) bool) bool
- func (s TypeSet) Remove(t Type) bool
- func (s TypeSet) RemoveM(m dogma.Message) bool
Constants ¶
This section is empty.
Variables ¶
var Roles = []Role{ CommandRole, EventRole, TimeoutRole, }
Roles is a slice of the valid message roles.
Functions ¶
func IsEqualSetN ¶ added in v0.7.1
func IsEqualSetN(a, b NameCollection) bool
IsEqualSetN returns true if a and b are equal.
That is, it returns true if and only if every element of a is an element of b, and vice-versa.
func IsEqualSetT ¶ added in v0.7.1
func IsEqualSetT(a, b TypeCollection) bool
IsEqualSetT returns true if a and b are equal.
That is, it returns true if and only if every element of a is an element of b, and vice-versa.
func IsIntersectingN ¶ added in v0.2.2
func IsIntersectingN(a, b NameCollection) bool
IsIntersectingN returns true if a and b are intersecting.
That is, it returns true if a and b contain any of the same names.
See https://en.wikipedia.org/wiki/Set_(mathematics)#Intersections.
func IsIntersectingT ¶ added in v0.2.2
func IsIntersectingT(a, b TypeCollection) bool
IsIntersectingT returns true if a and b are intersecting.
That is, it returns true if a and b contain any of the same types.
See https://en.wikipedia.org/wiki/Set_(mathematics)#Intersections.
func IsSubsetN ¶ added in v0.2.2
func IsSubsetN(sub, sup NameCollection) bool
IsSubsetN returns true if sub is a (non-strict) subset of sup.
That is, it returns true if sup contains all of the names in sub.
See https://en.wikipedia.org/wiki/Set_(mathematics)#Subsets.
func IsSubsetT ¶ added in v0.2.2
func IsSubsetT(sub, sup TypeCollection) bool
IsSubsetT returns true if sub is a (non-strict) subset of sup.
That is, it returns true if sup contains all of the types in sub.
See https://en.wikipedia.org/wiki/Set_(mathematics)#Subsets.
Types ¶
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name is the fully-qualified name of a message type.
func NameFromType ¶ added in v0.10.0
NameFromType returns the fully-qualified type name of t.
func (Name) MarshalBinary ¶
MarshalBinary returns a binary representation of the name.
func (Name) MarshalText ¶
MarshalText returns a UTF-8 representation of the name.
func (*Name) UnmarshalBinary ¶
UnmarshalBinary unmarshals a type from its binary representation.
func (*Name) UnmarshalText ¶
UnmarshalText unmarshals a name from its UTF-8 representation.
type NameCollection ¶
type NameCollection interface { // Has returns true if n is in the container. Has(n Name) bool // HasM returns true if NameOf(m) is in the container. HasM(m dogma.Message) bool // Len returns the number of names in the collection. Len() int // Range invokes fn once for each name in the container. // // Iteration stops when fn returns false or once fn has been invoked for all // names in the container. // // It returns true if fn returned true for all names. Range(fn func(Name) bool) bool }
NameCollection is an interface for containers of message names.
type NameRoles ¶
NameRoles is an implementation of NameCollection that maps message types to their roles.
func (NameRoles) Add ¶
Add maps n to r.
It returns true if the mapping was added, or false if the map already contained the name.
func (NameRoles) AddM ¶
AddM adds NameOf(m) to nr.
It returns true if the mapping was added, or false if the map already contained the name.
func (NameRoles) FilterByRole ¶ added in v0.7.0
FilterByRole returns the subset of names that have the given role.
func (NameRoles) IsEqual ¶ added in v0.2.0
IsEqual returns true if o contains the same names with the same roles as s.
func (NameRoles) Range ¶ added in v0.3.0
Range invokes fn once for each name in the container.
Iteration stops when fn returns false or once fn has been invoked for all names in the container.
It returns true if fn returned true for all names.
func (NameRoles) RangeByRole ¶ added in v0.7.0
RangeByRole invokes fn once for each name in the container that maps to the given role.
Iteration stops when fn returns false or once fn has been invoked for all names in the container.
It returns true if fn returned true for all names.
type NameSet ¶
type NameSet map[Name]struct{}
NameSet is an implementation of NameCollection that contains a distinct set of message names.
func DiffN ¶ added in v0.2.2
func DiffN(a, b NameCollection) NameSet
DiffN returns the difference between a and b.
That is, it returns a set containing all of the names present in a that are not present in b.
See https://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement.
func IntersectionN ¶ added in v0.2.2
func IntersectionN(collections ...NameCollection) NameSet
IntersectionN returns the intersection of the given collections.
That is, it returns a set containing only those names that are present in all of the given collections. It returns an empty set if no collections are given.
See https://en.wikipedia.org/wiki/Intersection_(set_theory).
func NewNameSet ¶
NewNameSet returns a NameSet containing the given names.
func UnionN ¶ added in v0.2.2
func UnionN(collections ...NameCollection) NameSet
UnionN returns the union of the given collections.
That is, it returns a set containing all of the names present in all of the given collections. It returns an empty set if no collections are given.
func (NameSet) Add ¶
Add adds n to s.
It returns true if the name was added, or false if the set already contained the name.
func (NameSet) AddM ¶
AddM adds NameOf(m) to s.
It returns true if the name was added, or false if the set already contained the name.
func (NameSet) Range ¶ added in v0.3.0
Range invokes fn once for each name in the container.
Iteration stops when fn returns false or once fn has been invoked for all names in the container.
It returns true if fn returned true for all names.
type Role ¶
type Role string
Role is an enumeration of the roles a message can perform within an application.
func (Role) Marker ¶
Marker returns a character that identifies the message role when displaying message types.
func (Role) MarshalBinary ¶
MarshalBinary returns a binary representation of the message role.
func (Role) MarshalText ¶
MarshalText returns a UTF-8 representation of the message role.
func (Role) MustValidate ¶
func (r Role) MustValidate()
MustValidate panics if r is not a valid message role.
func (Role) ShortString ¶
ShortString returns a short (3-character) representation of the handler type.
func (*Role) UnmarshalBinary ¶
UnmarshalBinary unmarshals a role from its binary representation.
func (*Role) UnmarshalText ¶
UnmarshalText unmarshals a role from its UTF-8 representation.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents the type of a Dogma message.
func TypeFromReflect ¶ added in v0.4.1
TypeFromReflect returns the message type of the given reflect type.
func (Type) Name ¶
Name returns the fully-qualified name for the Go type.
It panics if t.IsZero() returns true.
func (Type) ReflectType ¶
ReflectType returns the reflect.Type of the message.
It panics if t.IsZero() returns true.
type TypeCollection ¶
type TypeCollection interface { // Has returns true if t is in the container. Has(t Type) bool // HasM returns true if TypeOf(m) is in the container. HasM(m dogma.Message) bool // Len returns the number of names in the collection. Len() int // Range invokes fn once for each type in the container. // // Iteration stops when fn returns false or once fn has been invoked for all // types in the container. // // It returns true if fn returned true for all types. Range(fn func(Type) bool) bool }
TypeCollection is an interface for containers of message types.
type TypeRoles ¶
TypeRoles is an implementation of TypeCollection that maps message types to their roles.
func (TypeRoles) Add ¶
Add maps t to r.
It returns true if the mapping was added, or false if the map already contained the type.
func (TypeRoles) AddM ¶
AddM adds TypeOf(m) to tr.
It returns true if the mapping was added, or false if the map already contained the type.
func (TypeRoles) FilterByRole ¶ added in v0.7.0
FilterByRole returns the subset of types that have the given role.
func (TypeRoles) IsEqual ¶ added in v0.2.0
IsEqual returns true if o contains the same types with the same roles as tr.
func (TypeRoles) Range ¶ added in v0.3.0
Range invokes fn once for each type in the container.
Iteration stops when fn returns false or once fn has been invoked for all types in the container.
It returns true if fn returned true for all types.
func (TypeRoles) RangeByRole ¶ added in v0.7.0
RangeByRole invokes fn once for each type in the container that maps to the given role.
Iteration stops when fn returns false or once fn has been invoked for all types in the container.
It returns true if fn returned true for all types.
type TypeSet ¶
type TypeSet map[Type]struct{}
TypeSet is an implementation of TypeCollection that contains a distinct set of message types.
func DiffT ¶ added in v0.2.2
func DiffT(a, b TypeCollection) TypeSet
DiffT returns the difference between a and b.
That is, it returns a set containing all of the types present in a that are not present in b.
See https://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement.
func IntersectionT ¶ added in v0.2.2
func IntersectionT(collections ...TypeCollection) TypeSet
IntersectionT returns the intersection of the given collections.
That is, it returns a set containing only those types that are present in all of the given collections. It returns an empty set if no collections are given.
See https://en.wikipedia.org/wiki/Intersection_(set_theory).
func NewTypeSet ¶
NewTypeSet returns a TypeSet containing the given types.
func UnionT ¶ added in v0.2.2
func UnionT(collections ...TypeCollection) TypeSet
UnionT returns the union of the given collections.
That is, it returns a set containing all of the types present in all of the given collections. It returns an empty set if no collections are given.
func (TypeSet) Add ¶
Add adds t to s.
It returns true if the type was added, or false if the set already contained the type.
func (TypeSet) AddM ¶
AddM adds TypeOf(m) to s.
It returns true if the type was added, or false if the set already contained the type.
func (TypeSet) Range ¶ added in v0.3.0
Range invokes fn once for each type in the container.
Iteration stops when fn returns false or once fn has been invoked for all types in the container.
It returns true if fn returned true for all types.