MessageStore::StreamName

MessageStore::StreamName is a function library of basic utilities for composing and parsing stream names.

MessageStore::StreamName Facts

  • MessageStore::StreamName module's methods cannot be mixed into a class
  • Its methods can only be invoked from the MessageStore::StreamName constant
  • Methods in the Messaging::StreamName module are built upon and delegate to the MessageStore::StreamName module.

MessageStore::StreamName Module

The StreamName module is a function library from the MessageStore library and namespace.

The StreamName module provides:

  • The stream_name module for composing a stream name from its constituent parts
  • The get_id method for parsing a stream's ID from a stream name
  • The get_category method for parsing a stream's category from a stream name
  • The category? predicate for determining whether a stream name is a category stream name
  • The get_types method for parsing a stream's category types from a stream name
  • The get_type_list method for parsing a stream's category type list from a stream name

Stream Name

Compose a stream name from its constituent parts.

self.stream_name(category_name, id=nil, type: nil, types: nil)

Returns

String

Parameters

NameDescriptionType
categoryThe stream's category nameString
idID of the entity represented by the streamString
typeThe stream's category type, if only one typeString
typesThe stream's list category types, if many typesArray of Strings
MessageStore::StreamName.stream_name('someEntity')
# => "someEntity"

MessageStore::StreamName.stream_name('someEntity', '123')
# => "someEntity-123"

MessageStore::StreamName.stream_name('someEntity', '123', type: 'someType')
# => "someEntity:someType-123"

MessageStore::StreamName.stream_name('someEntity', '123', types: ['someType', 'someOtherType'])
# => "someEntity:someType+someOtherType-123"

Get ID from Stream Name

self.get_id(stream_name)

Returns

String

Parameters

NameDescriptionType
stream_nameThe stream name from which to get the IDString
MessageStore::StreamName.get_id('someEntity-123')
# => '123'

Get Category from Stream Name

self.get_category(stream_name)

Returns

String

Parameters

NameDescriptionType
stream_nameThe stream name from which to get the categoryString
MessageStore::StreamName.get_category('someEntity-123')
# => 'someEntity'

Determine Whether a Stream Name is for a Category Stream

def self.category?(stream_name)

Returns

Boolean

Parameters

NameDescriptionType
stream_nameThe stream name to determine whether it's a category stream nameString
MessageStore::StreamName.category?('someEntity')
# => true

MessageStore::StreamName.category?('someEntity-123')
# => false

Get Types from Stream Name

self.get_types(stream_name)

Returns

Array of Strings

Parameters

NameDescriptionType
stream_nameThe stream name from which to get the typesString
MessageStore::StreamName.get_types('someEntity:someType+someOtherType-123')
# => ["someType", "someOtherType"]

Get Type List from Stream Name

self.get_type_list(stream_name)

Returns

String

Parameters

NameDescriptionType
stream_nameThe stream name from which to get the type listString
MessageStore::StreamName.get_type_list('someEntity:someType+someOtherType-123')
# => "someType+someOtherType"