types

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 9 Imported by: 12

Documentation

Overview

Package type defines the common data structures used internally and for defining tests/strategies in Netrix.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoData occurs when [Message.Data] is empty
	ErrNoData = errors.New("no data in message")
	// ErrBadParse occurs when [MessageParser] is nil
	ErrBadParser = errors.New("bad parser")
)

Errors that can occur when parsing a message

View Source
var (
	// ErrReplicaStoreFull is returned when more than the intended number of replicas register with the scheduler tool
	ErrReplicaStoreFull = errors.New("replica store is full")
)

Functions

func GetParsedMessage added in v0.2.4

func GetParsedMessage[V any](m *Message) (V, bool)

GetParsedMessage[V] type casts [Message.ParsedMessage] to the specified type V.

func Max added in v0.2.0

func Max[T constraints.Ordered](one, two T) T

Max[T] abstracts the max function for all ordered types T

func VarSetGet added in v0.2.0

func VarSetGet[T any](v *VarSet, label string) (T, bool)

VarSetGet returns the value with the specified label and typecasts it

Types

type BaseService

type BaseService struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

BaseService provides the basic nuts an bolts needed to implement a service

func NewBaseService

func NewBaseService(name string, parentLogger *log.Logger) *BaseService

NewBaseService instantiates BaseService

func (*BaseService) Name

func (b *BaseService) Name() string

Name returns the name of the service.

func (*BaseService) QuitCh

func (b *BaseService) QuitCh() <-chan struct{}

QuitCh returns the quit channel which will be closed when the service stops running.

func (*BaseService) Running

func (b *BaseService) Running() bool

Running returns the flag.

func (*BaseService) SetLogger added in v0.1.3

func (b *BaseService) SetLogger(logger *log.Logger)

SetLogger assigns to [BaseService.Logger] the specified value.

func (*BaseService) StartRunning

func (b *BaseService) StartRunning()

StartRunning is called to set the running flag

func (*BaseService) StopRunning

func (b *BaseService) StopRunning()

StopRunning is called to unset the running flag.

type Channel added in v0.2.1

type Channel[V any] struct {
	// contains filtered or unexported fields
}

Channel[V] is a synchronized channel that can be reset (closed and opened) multiple times.

The data structure is useful when we need to close the channel and re-open a new one in a multi threaded environment. The underlying channel is encapsulated with a Mutex lock.

Example:

ch := NewChannel[int]

go func() {
	for {
		select {
		case <-ch.Ch():
			//...
		}
	}
}()

ch.BlockingAdd(1)
ch.BlockingAdd(2)
ch.Close()
ch.Open()
//...

func NewChannel added in v0.2.1

func NewChannel[V any]() *Channel[V]

NewChannel[V] creates a Channel[V] object.

func (*Channel[V]) BlockingAdd added in v0.2.7

func (c *Channel[V]) BlockingAdd(element V)

BlockingAdd waits until the channel is not full to add.

func (*Channel[V]) Ch added in v0.2.2

func (c *Channel[V]) Ch() chan V

Ch returns the underlying channel that can be used to poll

func (*Channel[V]) Close added in v0.2.2

func (c *Channel[V]) Close()

Close closes the channel

func (*Channel[V]) IsOpen added in v0.2.7

func (c *Channel[V]) IsOpen() bool

IsOpen returns true if the channel is open

func (*Channel[V]) NonBlockingAdd added in v0.2.7

func (c *Channel[V]) NonBlockingAdd(element V) bool

NonBlockingAdd adds the element if the underlying channel is not full, results in a no-op otherwise.

func (*Channel[V]) Open added in v0.2.2

func (c *Channel[V]) Open()

Open clears the previous channel and unlocks it

func (*Channel[V]) Reset added in v0.2.1

func (c *Channel[V]) Reset()

Reset closes the underlying channel and creates a new one.

type ClockValue

type ClockValue map[ReplicaID]int

ClockValue represents a vector clock value

func ZeroClock added in v0.1.1

func ZeroClock() ClockValue

ZeroClock creates a new empty ClockValue

func (ClockValue) Lt

func (c ClockValue) Lt(other ClockValue) bool

Lt returns true if c < other

func (ClockValue) Next added in v0.2.1

func (c ClockValue) Next(replica ReplicaID) ClockValue

Next increments the clock value for the specified replica when it has been initialized and sets it to 0 otherwise

type Clonable

type Clonable interface {
	Clone() Clonable
}

Clonable is any type which returns a copy of itself on Clone()

type Counter added in v0.1.1

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

Counter threadsafe counter

func NewCounter added in v0.1.1

func NewCounter() *Counter

NewCounter returns a counter

func (*Counter) Incr added in v0.1.1

func (c *Counter) Incr()

Incr increments the counter

func (*Counter) SetValue added in v0.1.1

func (c *Counter) SetValue(v int)

SetValue sets the counter to the specified value

func (*Counter) Value added in v0.1.1

func (c *Counter) Value() int

Value returns the counter value

type Event

type Event struct {
	// Replica at which the event occurs
	Replica ReplicaID `json:"replica"`
	// Type of the event
	Type EventType `json:"-"`
	// TypeS is the string representation of the event
	TypeS string `json:"type"`
	// ID unique identifier assigned for every new event
	ID EventID `json:"id"`
	// Timestamp of the event
	Timestamp int64 `json:"timestamp"`
}

Event is a generic event that occurs at a replica

func NewEvent

func NewEvent(replica ReplicaID, t EventType, ts string, id EventID, time int64) *Event

NewEvent creates an Event with the specified values

func (*Event) Clone

func (e *Event) Clone() Clonable

Clone implements Clonable

func (*Event) IsGeneric added in v0.1.5

func (e *Event) IsGeneric() bool

IsGeneric is true when the event is of type GenericEventType.

func (*Event) IsMessageReceive

func (e *Event) IsMessageReceive() bool

IsMessageReceive is true when the event is of type message receive

func (*Event) IsMessageSend

func (e *Event) IsMessageSend() bool

IsMessageSend is true when the event is of type message send

func (*Event) IsTimeoutEnd

func (e *Event) IsTimeoutEnd() bool

IsTimeoutEnd returns true when the event is of type timeout end.

func (*Event) IsTimeoutStart

func (e *Event) IsTimeoutStart() bool

IsTimeoutStart returns true when the event is of type timeout start.

func (*Event) MessageID

func (e *Event) MessageID() (MessageID, bool)

MessageID returns the message ID of the corresponding message when the event type is either a message send or a message receive. The second return value is false otherwise

func (*Event) Timeout

func (e *Event) Timeout() (*ReplicaTimeout, bool)

Timeout returns the corresponding timeout if the event is of type either timeout start or timeout end. The second return value is false otherwise.

type EventDAG

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

EventDAG is directed acyclic graph (DAG) of the events.

The DAG can be traversed and also used to compare two events The nodes of the DAG are represented by EventNode which contains information about parents and children. Recursively enumerating the parents, children of the EventNode allows one to traverse the DAG

func NewEventDag

func NewEventDag(replicaStore *ReplicaStore) *EventDAG

NewEventDag creates a new EventDAG

func (*EventDAG) AddNode

func (d *EventDAG) AddNode(e *Event, parents []*Event)

AddNode adds a new event with the specified parents to the DAG

Internally, the parents are inferred as follows. 1. The previous node in the same replica 2. The message send node when the new event is a message receive 3. The timeout start node when the new event is a timeout end

func (*EventDAG) GetLatestNode

func (d *EventDAG) GetLatestNode(replica ReplicaID) (*Event, bool)

GetLatestNode returns the latest event for the specified replica if one exists.

func (*EventDAG) GetNode

func (d *EventDAG) GetNode(eid EventID) (*EventNode, bool)

GetNode returns the EventNode of the corresponding event when it is part of the DAG, the second parameter is false otherwise.

func (*EventDAG) MarshalJSON

func (d *EventDAG) MarshalJSON() ([]byte, error)

func (*EventDAG) Reset added in v0.1.4

func (d *EventDAG) Reset()

Reset clears the DAG

type EventID added in v0.1.1

type EventID uint64

EventID is a unique identifier for each event

type EventNode

type EventNode struct {
	Event      *Event     `json:"event"`
	ClockValue ClockValue `json:"-"`

	Parents  *EventNodeSet `json:"parents"`
	Children *EventNodeSet `json:"children"`
	// contains filtered or unexported fields
}

EventNode encapsulates an Event with information about parents, children, clock value. Represents a node in the EventDAG.

func NewEventNode

func NewEventNode(e *Event) *EventNode

NewEventNode creates a new EventNode

func (*EventNode) AddParents

func (n *EventNode) AddParents(parents []*EventNode)

AddParents add to the Parents event node set.

func (*EventNode) Clone

func (n *EventNode) Clone() *EventNode

Clone returns a copy of the event node

func (*EventNode) GetNext

func (n *EventNode) GetNext() EventID

GetNext returns the next event in the same replica

func (*EventNode) GetPrev

func (n *EventNode) GetPrev() EventID

GetPrev returns the previous node for the same replica

func (*EventNode) Lt added in v0.1.1

func (n *EventNode) Lt(other *EventNode) bool

Lt returns true when the underlying Events are related by cur < other

func (*EventNode) SetClock added in v0.1.1

func (n *EventNode) SetClock(cv ClockValue)

SetClock sets the vector clock value

func (*EventNode) SetNext

func (n *EventNode) SetNext(next EventID)

SetNext sets the next event for the current node

func (*EventNode) SetPrev

func (n *EventNode) SetPrev(prev EventID)

SetPrev sets the previous node for the current node

type EventNodeSet

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

EventNodeSet is a thread safe node set.

func NewEventNodeSet

func NewEventNodeSet() *EventNodeSet

NewEventNodeSet creates an empty EventNodeSet

func (*EventNodeSet) Add

func (d *EventNodeSet) Add(nid EventID)

Add adds the event to the set

func (*EventNodeSet) Clone

func (d *EventNodeSet) Clone() *EventNodeSet

Clone returns a copy of the event node set

func (*EventNodeSet) Exists

func (d *EventNodeSet) Exists(nid EventID) bool

Exists returns true if the node is part of the set, false otherwise

func (*EventNodeSet) Iter

func (d *EventNodeSet) Iter() []EventID

Iter returns a list of the event node in a random order

func (*EventNodeSet) MarshalJSON

func (d *EventNodeSet) MarshalJSON() ([]byte, error)

func (*EventNodeSet) Size

func (d *EventNodeSet) Size() int

Size returns the size of the EventNodeSet

type EventType

type EventType interface {
	// Clone copies the event type
	Clone() EventType
	// Type is a unique key for that event type
	Type() string
	// String should return a string representation of the event type
	String() string
}

EventType abstract type for representing different types of events

type GenericEventType

type GenericEventType struct {
	// Marshalled parameters
	Params map[string]string `json:"params"`
	// Type of event for reference
	// Eg: Commit
	T string `json:"type"`
}

GenericEventType is the event type published by a replica It can be specific to the algorithm that is implemented

func NewGenericEventType

func NewGenericEventType(params map[string]string, t string) *GenericEventType

NewGenericEventType instantiates GenericEventType

func (*GenericEventType) Clone

func (g *GenericEventType) Clone() EventType

Clone returns a copy of the current GenericEventType

func (*GenericEventType) String

func (g *GenericEventType) String() string

String returns a string representation of the event type

func (*GenericEventType) Type

func (g *GenericEventType) Type() string

Type returns a unique key for GenericEventType

type List added in v0.1.5

type List[V any] struct {
	// contains filtered or unexported fields
}

List[V] is a generic thread safe list

func NewEmptyList added in v0.1.5

func NewEmptyList[V any]() *List[V]

NewEmptyList[V] creates an empty List

func NewList added in v0.1.5

func NewList[V any](cur []V) *List[V]

NewList[V] copies the contents of the specified list onto a new List object

func (*List[V]) Append added in v0.1.5

func (l *List[V]) Append(e V)

func (*List[V]) Elem added in v0.1.5

func (l *List[V]) Elem(index int) (V, bool)

func (*List[V]) Iter added in v0.1.5

func (l *List[V]) Iter() []V

func (*List[V]) RemoveAll added in v0.1.5

func (l *List[V]) RemoveAll() []V

func (*List[V]) Size added in v0.1.5

func (l *List[V]) Size() int

type Map added in v0.1.3

type Map[T constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

Map[T,V] is a generic thread safe map of key type [T] and value type [V]

func NewMap added in v0.1.3

func NewMap[T constraints.Ordered, V any]() *Map[T, V]

NewMap[T,V] creates an empty Map

func (*Map[T, V]) Add added in v0.1.3

func (s *Map[T, V]) Add(key T, val V)

func (*Map[T, V]) Exists added in v0.1.3

func (s *Map[T, V]) Exists(key T) bool

func (*Map[T, V]) Get added in v0.1.3

func (s *Map[T, V]) Get(key T) (V, bool)

func (*Map[T, V]) IterValues added in v0.1.3

func (s *Map[T, V]) IterValues() []V

func (*Map[T, V]) Keys added in v0.2.0

func (s *Map[T, V]) Keys() []T

func (*Map[T, V]) RandomValue added in v0.1.4

func (s *Map[T, V]) RandomValue() (V, bool)

func (*Map[T, V]) RandomValueWithSource added in v0.1.4

func (s *Map[T, V]) RandomValueWithSource(src rand.Source) (V, bool)

func (*Map[T, V]) Remove added in v0.1.3

func (s *Map[T, V]) Remove(key T)

func (*Map[T, V]) RemoveAll added in v0.1.3

func (s *Map[T, V]) RemoveAll()

func (*Map[T, V]) Size added in v0.1.3

func (s *Map[T, V]) Size() int

func (*Map[T, V]) ToMap added in v0.1.3

func (s *Map[T, V]) ToMap() map[T]V

type Message

type Message struct {
	From          ReplicaID     `json:"from"`
	To            ReplicaID     `json:"to"`
	Data          []byte        `json:"data"`
	Type          string        `json:"type"`
	ID            MessageID     `json:"id"`
	Intercept     bool          `json:"intercept"`
	ParsedMessage ParsedMessage `json:"-"`
	Repr          string        `json:"repr"`
}

Message stores a message that has been intercepted between two replicas

func (*Message) Clone

func (m *Message) Clone() Clonable

Clone to create a new Message object with the same attributes.

func (*Message) Name added in v0.3.2

func (m *Message) Name() string

Name returns a formatted string containing from, to and repr Name is not unique for every message, use ID for that purpose

func (*Message) Parse

func (m *Message) Parse(parser MessageParser) error

Parse invokes [MessageParser.Parse] with [Message.Data] and the result is stored in [Message.ParsedMessage].

type MessageID added in v0.1.3

type MessageID string

MessageID is a unique identifier for each message

type MessageParser

type MessageParser interface {
	// Parse accepts a byte array and returns a ParsedMessage when successfully parsed, an error otherwise.
	Parse([]byte) (ParsedMessage, error)
}

MessageParser defines a generic parsing interface.

The specific implementation is particular to the protocol being tested.

type MessageReceiveEventType

type MessageReceiveEventType struct {
	// MessageID is the ID of the message received
	MessageID MessageID
}

MessageReceiveEventType is the event type when a replica receives a message

func NewMessageReceiveEventType

func NewMessageReceiveEventType(messageID string) *MessageReceiveEventType

NewMessageReceiveEventType instantiates MessageReceiveEventType

func (*MessageReceiveEventType) Clone

Clone returns a copy of the current MessageReceiveEventType

func (*MessageReceiveEventType) String

func (r *MessageReceiveEventType) String() string

String returns a string representation of the event type

func (*MessageReceiveEventType) Type

func (r *MessageReceiveEventType) Type() string

Type returns a unique key for MessageReceiveEventType

type MessageSendEventType

type MessageSendEventType struct {
	// MessageID of the message that was sent
	MessageID MessageID
}

MessageSendEventType is the event type where a message is sent from the replica

func NewMessageSendEventType

func NewMessageSendEventType(messageID string) *MessageSendEventType

NewMessageSendEventType instantiates MessageSendEventType

func (*MessageSendEventType) Clone

func (s *MessageSendEventType) Clone() EventType

Clone returns a copy of the current MessageSendEventType

func (*MessageSendEventType) String

func (s *MessageSendEventType) String() string

String returns a string representation of the event type

func (*MessageSendEventType) Type

func (s *MessageSendEventType) Type() string

Type returns a unique key for MessageSendEventType

type ParsedMessage

type ParsedMessage interface {
	// String should return a succinct representation of the message. used for logging.
	String() string
	// Clone should create a copy of the current ParsedMessage
	Clone() ParsedMessage
	// Marshal should serialize the ParsedMessage.
	//
	// The byte stream when passed to [MessageParser.Parse] should result in the same ParsedMessage
	Marshal() ([]byte, error)
}

ParsedMessage encapsulates a message returned by MessageParser

type Queue added in v0.1.3

type Queue[V Clonable] struct {
	*BaseService
	// contains filtered or unexported fields
}

Queue is a generic pub-sub queue that is thread safe

func NewQueue added in v0.1.3

func NewQueue[V Clonable](logger *log.Logger) *Queue[V]

NewQueue[V] returns an empty Queue[V]

func (*Queue[V]) Add added in v0.1.3

func (q *Queue[V]) Add(m V)

Add adds a message to the queue

func (*Queue[V]) Flush added in v0.1.3

func (q *Queue[V]) Flush()

Flush clears the queue of all messages

func (*Queue[V]) Pause added in v0.2.1

func (q *Queue[V]) Pause()

Pause stops accepting queue elements (discards them instead)

func (*Queue[V]) Pop added in v0.2.1

func (q *Queue[V]) Pop() (V, bool)

Pop returns an element at the head of the queue

func (*Queue[V]) Restart added in v0.1.3

func (q *Queue[V]) Restart() error

Restart implements Service

func (*Queue[V]) Resume added in v0.2.1

func (q *Queue[V]) Resume()

Resume stops discarding and starts accepting elements

func (*Queue[V]) Start added in v0.1.3

func (q *Queue[V]) Start() error

Start implements Service

func (*Queue[V]) Stop added in v0.1.3

func (q *Queue[V]) Stop() error

Stop implements Service

func (*Queue[V]) Subscribe added in v0.1.3

func (q *Queue[V]) Subscribe(label string) *Channel[V]

Subscribe creates and returns a channel for the subscriber with the given label

type Replica

type Replica struct {
	ID    ReplicaID              `json:"id"`
	Ready bool                   `json:"ready"`
	Info  map[string]interface{} `json:"info"`
	Addr  string                 `json:"addr"`
	// contains filtered or unexported fields
}

Replica immutable representation of the attributes of a replica

type ReplicaID

type ReplicaID string

ReplicaID is an identifier for the replica encoded as a string

type ReplicaStore

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

ReplicaStore to store all replica information, thread safe

func NewReplicaStore

func NewReplicaStore(size int) *ReplicaStore

NewReplicaStore creates an empty ReplicaStore

func (*ReplicaStore) Add

func (s *ReplicaStore) Add(p *Replica)

Add adds or updates a replica to the store

func (*ReplicaStore) Cap

func (s *ReplicaStore) Cap() int

Cap returns the set of replicas used for the test

func (*ReplicaStore) Count

func (s *ReplicaStore) Count() int

Count returns the total number of replicas

func (*ReplicaStore) Get

func (s *ReplicaStore) Get(id ReplicaID) (p *Replica, ok bool)

Get returns the replica and a bool indicating if it exists or not

func (*ReplicaStore) GetRandom added in v0.1.1

func (s *ReplicaStore) GetRandom() (*Replica, bool)

func (*ReplicaStore) Iter

func (s *ReplicaStore) Iter() []*Replica

Iter returns a list of the existing replicas

func (*ReplicaStore) NumReady

func (s *ReplicaStore) NumReady() int

NumReady returns the number of replicas with Ready attribute set to true

func (*ReplicaStore) ResetReady

func (s *ReplicaStore) ResetReady()

ResetReady sets the Ready attribute of all replicas to false

type ReplicaTimeout

type ReplicaTimeout struct {
	Replica  ReplicaID     `json:"replica"`
	Type     string        `json:"type"`
	Duration time.Duration `json:"duration"`
}

func TimeoutFromParams

func TimeoutFromParams(replica ReplicaID, params map[string]string) (*ReplicaTimeout, bool)

func (*ReplicaTimeout) Eq

func (t *ReplicaTimeout) Eq(other *ReplicaTimeout) bool

func (*ReplicaTimeout) Key added in v0.1.3

func (t *ReplicaTimeout) Key() string

func (*ReplicaTimeout) MarshalJSON

func (t *ReplicaTimeout) MarshalJSON() ([]byte, error)

type ReportLogs added in v0.1.3

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

func NewReportLogs added in v0.1.3

func NewReportLogs() *ReportLogs

func (*ReportLogs) GetLogs added in v0.1.3

func (r *ReportLogs) GetLogs(keyvals map[string]string, count int, from int) []*reportLog

func (*ReportLogs) Log added in v0.1.3

func (r *ReportLogs) Log(keyvals map[string]string)

type RestartableService

type RestartableService interface {
	Service
	// Restart restarts the service
	Restart() error
}

RestartableService is a service which can be restarted

type Service

type Service interface {
	// Name of the service
	Name() string
	// Start to start the service
	Start() error
	// Running to indicate if the service is running
	Running() bool
	// Stop to stop the service
	Stop() error
	// Quit returns a channel which will be closed once the service stops running
	QuitCh() <-chan struct{}
	// SetLogger initializes the logger for the service
	SetLogger(*log.Logger)
}

Service is any entity which runs on a separate thread

type Set added in v0.2.0

type Set[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

Set[T] is thread safe generic set implementation

func NewSet added in v0.2.0

func NewSet[T constraints.Ordered]() *Set[T]

NewSet[T] creates an empty Set

func (*Set[T]) Add added in v0.2.0

func (s *Set[T]) Add(elem T)

func (*Set[T]) Contains added in v0.2.0

func (s *Set[T]) Contains(elem T) bool

func (*Set[T]) Iter added in v0.2.0

func (s *Set[T]) Iter() []T

func (*Set[T]) Remove added in v0.2.0

func (s *Set[T]) Remove(elem T)

func (*Set[T]) Size added in v0.2.0

func (s *Set[T]) Size() int

type TimeoutEndEventType

type TimeoutEndEventType struct {
	Timeout *ReplicaTimeout
}

TimeoutEndEventType represents a timeout end event

func NewTimeoutEndEventType

func NewTimeoutEndEventType(timeout *ReplicaTimeout) *TimeoutEndEventType

NewTimeoutEndEventType creates a new [TimeoutEventEventType]

func (*TimeoutEndEventType) Clone

func (te *TimeoutEndEventType) Clone() EventType

Clone returns a copy

func (*TimeoutEndEventType) String

func (te *TimeoutEndEventType) String() string

String serializes the timeout end event type

func (*TimeoutEndEventType) Type

func (te *TimeoutEndEventType) Type() string

Type returns "TimeoutEndEventType"

type TimeoutStartEventType

type TimeoutStartEventType struct {
	Timeout *ReplicaTimeout
}

TimeoutStartEventType represents a timeout start event

func NewTimeoutStartEventType

func NewTimeoutStartEventType(timeout *ReplicaTimeout) *TimeoutStartEventType

NewTimeoutStartEventType creates a new TimeoutStartEventType with the specified timeout

func (*TimeoutStartEventType) Clone

func (ts *TimeoutStartEventType) Clone() EventType

Clone returns a copy

func (*TimeoutStartEventType) String

func (ts *TimeoutStartEventType) String() string

String serializes the timeout start event

func (*TimeoutStartEventType) Type

func (ts *TimeoutStartEventType) Type() string

Type returns "TimeoutStartEventType"

type VarSet added in v0.1.1

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

VarSet is a dictionary for storing auxiliary state during the execution of the testcase VarSet is stored in the context passed to actions and conditions

func NewVarSet added in v0.1.1

func NewVarSet() *VarSet

NewVarSet instantiates Vars

func (*VarSet) Exists added in v0.1.1

func (v *VarSet) Exists(label string) bool

Exists returns true if there is a variable of the specified key

func (*VarSet) Get added in v0.1.1

func (v *VarSet) Get(label string) (interface{}, bool)

Get returns the value stored of the specified label the second return argument is false if the label does not exist

func (*VarSet) GetBool added in v0.1.1

func (v *VarSet) GetBool(label string) (bool, bool)

GetBool casts the value at label (if it exists) into boolean and returns it

func (*VarSet) GetCounter added in v0.1.1

func (v *VarSet) GetCounter(label string) (*Counter, bool)

GetCounter returns the counter at the label if it exists (nil, false) otherwise

func (*VarSet) GetInt added in v0.1.1

func (v *VarSet) GetInt(label string) (int, bool)

GetInt casts the value at label (if it exists) into integer and returns it

func (*VarSet) GetMessageSet added in v0.1.1

func (v *VarSet) GetMessageSet(label string) (*Map[MessageID, *Message], bool)

GetMessageSet returns the message set at label if one exists (nil, false) otherwise

func (*VarSet) GetString added in v0.1.1

func (v *VarSet) GetString(label string) (string, bool)

GetString casts the value at label (if it exists) into string and returns it

func (*VarSet) Keys added in v0.2.1

func (v *VarSet) Keys() []string

func (*VarSet) NewMessageSet added in v0.1.1

func (v *VarSet) NewMessageSet(label string)

NewMessageSet creates a message set at the specified label

func (*VarSet) Reset added in v0.2.1

func (v *VarSet) Reset()

Reset removes all vars in the varset

func (*VarSet) Set added in v0.1.1

func (v *VarSet) Set(label string, value interface{})

Set the value at the specified label

func (*VarSet) SetCounter added in v0.1.1

func (v *VarSet) SetCounter(label string)

SetCounter sets a counter instance at the specified label with initial value 1

Jump to

Keyboard shortcuts

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