Skip to content
Snippets Groups Projects
Commit fa79a577 authored by Josh Brooks's avatar Josh Brooks
Browse files

Implement dummy message in bindings

parent ab20037f
No related branches found
No related tags found
2 merge requests!510Release,!329Hotfix/dummy message bindings
...@@ -12,19 +12,29 @@ import ( ...@@ -12,19 +12,29 @@ import (
"time" "time"
) )
// DummyTraffic contains the file dummy traffic manager. The manager can be used // DummyTraffic is the bindings-layer dummy (or "cover") traffic manager. T
// to set and get the status of the send thread. // The manager can be used to set and get the status of the thread responsible for
// sending dummy messages.
type DummyTraffic struct { type DummyTraffic struct {
m *dummy.Manager m *dummy.Manager
} }
// NewDummyTrafficManager creates a DummyTraffic manager and initialises the // NewDummyTrafficManager creates a DummyTraffic manager and initialises the
// dummy traffic send thread. Note that the manager does not start sending dummy // dummy traffic sending thread. Note that the manager does not start sending dummy
// traffic until its status is set to true using DummyTraffic.SetStatus. // traffic until `True` is passed into DummyTraffic.SetStatus. The time duration
// The maxNumMessages is the upper bound of the random number of messages sent // between each sending operation and the amount of messages sent each interval
// each send. avgSendDeltaMS is the average duration, in milliseconds, to wait // are randomly generated values with bounds defined by the
// between sends. Sends occur every avgSendDeltaMS +/- a random duration with an // given parameters below.
// upper bound of randomRangeMS. //
// Params:
// - e2eID - e2e object ID in the tracker.
// - maxNumMessages - the upper bound of the random number of messages sent
// each sending cycle.
// - avgSendDeltaMS - the average duration, in milliseconds, to wait
// between sends.
// - randomRangeMS - the upper bound of the interval between sending cycles.
// Sends occur every avgSendDeltaMS +/- a random duration with an
// upper bound of randomRangeMS
func NewDummyTrafficManager(e2eID, maxNumMessages, avgSendDeltaMS, func NewDummyTrafficManager(e2eID, maxNumMessages, avgSendDeltaMS,
randomRangeMS int) (*DummyTraffic, error) { randomRangeMS int) (*DummyTraffic, error) {
...@@ -43,24 +53,32 @@ func NewDummyTrafficManager(e2eID, maxNumMessages, avgSendDeltaMS, ...@@ -43,24 +53,32 @@ func NewDummyTrafficManager(e2eID, maxNumMessages, avgSendDeltaMS,
return &DummyTraffic{m}, user.api.AddService(m.StartDummyTraffic) return &DummyTraffic{m}, user.api.AddService(m.StartDummyTraffic)
} }
// SetStatus sets the state of the dummy traffic send thread, which determines // SetStatus sets the state of the dummy traffic send thread by passing in
// if the thread is running or paused. The possible statuses are: // a boolean parameter. There may be a small delay in between this call
// true = send thread is sending dummy messages // and the status of the sending thread to change accordingly. For example,
// false = send thread is paused/stopped and not sending dummy messages // passing False into this call while the sending thread is currently sending messages
// Returns an error if the channel is full. // will not cancel nor halt the sending operation, but will pause the thread once that
// Note that this function cannot change the status of the send thread if it has // operation has completed.
// yet to be started or stopped. //
// Params:
// - boolean - True: Sending thread is sending dummy messages.
// False: Sending thread is paused/stopped and is not sending dummy messages
// Returns:
// - error - if the DummyTraffic.SetStatus is called too frequently, causing the
// internal status channel to fill.
func (dt *DummyTraffic) SetStatus(status bool) error { func (dt *DummyTraffic) SetStatus(status bool) error {
return dt.m.SetStatus(status) return dt.m.SetStatus(status)
} }
// GetStatus returns the current state of the dummy traffic send thread. It has // GetStatus returns the current state of the dummy traffic sending thread.
// the following return values: // Note that this function does not return the status set by the most recent call to
// true = send thread is sending dummy messages // SetStatus directly. Instead, this call returns the current status of the sending thread.
// false = send thread is paused/stopped and not sending dummy messages // This is due to the small delay that may occur between calling SetStatus and the
// Note that this function does not return the status set by SetStatus directly; // sending thread taking into effect that status change.
// it returns the current status of the send thread, which means any call to //
// SetStatus will have a small delay before it is returned by GetStatus. // Returns:
// - boolean - True: Sending thread is sending dummy messages.
// - False: Sending thread is paused/stopped and is not sending dummy messages.
func (dt *DummyTraffic) GetStatus() bool { func (dt *DummyTraffic) GetStatus() bool {
return dt.m.GetStatus() return dt.m.GetStatus()
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment