Documentation ¶
Index ¶
Constants ¶
const KeyUserID = "userId"
KeyUserID contains the User property key for its ID
Variables ¶
This section is empty.
Functions ¶
func GetRandomUserProperties ¶
GetRandomUserProperties creates a map with predefined user properties
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher makes sure the users are spawned and killed accordnly to the TrafficPattern pattern
func NewDispatcher ¶
func NewDispatcher(queen UserGenerator) *Dispatcher
NewDispatcher is making sure that [traffic.Next()] users are running and in total generating [eventsPerUserMin] events. The Traffic.next()] is called each [intervalSize].
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start(intervalSize time.Duration)
Start ticking and adjusting the online users based on the traffic pattern
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop pauses the dispatcher, the online users will still SEND events, but their numbers will not fluctuate any more
type Event ¶
type Event interface { Name() string Properties() map[string]string AddProperty(key, value string) }
Event identifies an Analytics Event
type EventGenerator ¶
EventGenerator is a simple functions that generate n events
type RandomEventGenerator ¶
type RandomEventGenerator struct {
// contains filtered or unexported fields
}
RandomEventGenerator creates random fake events
func NewRandomEventGenerator ¶
func NewRandomEventGenerator(templateEvents []Event) *RandomEventGenerator
NewRandomEventGenerator creates a Fake event generator based on a predefined set of patterns templateEvents must contains properties, and in their values FastFaker templates. ["price" => "###.##", "productCategory" => "{word}] each event generated will be based on these patterns, with fake data replacing the templates
func (*RandomEventGenerator) NewEvents ¶
func (g *RandomEventGenerator) NewEvents(count int) []Event
NewEvents creates new fake events
type User ¶
type User interface { // Properties of an user like userID, OS ... Property(key string) (string, error) SetProperty(key, value string) }
User represents a fake user that generates analytics
func NewSimpleUser ¶
func NewSimpleUser(eventsPerMin int, evg EventGenerator, out chan<- Event, minMs, maxMs int) User
NewSimpleUser must use the evg to generate eventsPerMin events and send them to the out channel, at random intervals.
type UserGenerator ¶
type UserGenerator func() User
UserGenerator generates one new random users at each call.