producer

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const KeyUserID = "userId"

KeyUserID contains the User property key for its ID

Variables

This section is empty.

Functions

func GetRandomUserProperties

func GetRandomUserProperties() map[string]string

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

func NewSimpleEvent

func NewSimpleEvent(name string, props map[string]string) Event

NewSimpleEvent creates a simple event based on input

type EventGenerator

type EventGenerator func(n int) []Event

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.

Jump to

Keyboard shortcuts

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