fake

package
v0.0.0-...-96f1409 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// ID is a unique event identifier
	ID string `json:"id"`

	// Station is a medium cardinality (1000s) string that has a 1 to many association with Events
	Station string `json:"station"`

	// UserID is a high cardinality (100s of millions) identifier that has a 1 to many association with events.
	UserID int `json:"user_id"`

	// Time the event occured. TODO how is it encoded?
	Timestamp string `json:"timestamp"`

	// A set of medium cardinality items to associate with this event.
	Favorites []string `json:"favorites"`

	// Set of complex objects.
	Items []Item `json:"items"`

	// Ordered list of objects.
	Ranking []Item `json:"ranking"`

	IfaceThing Interface `json:"ifacething"`

	// An integer with a set range of possible values to associate with this event.
	Velocity int `json:"velocity"`

	// A boolean to associate with this event.
	Active bool `json:"active"`

	// Another boolean at the top level.
	Alive bool `json:"alive"`

	// One more boolean with mixed case.
	DeceasedBoolean bool `json:"deceasedBoolean"`

	// The location of this event.
	Geo Geo `json:"geo"`
}

Event is an example event that includes a variety of types.

func GenEvent

func GenEvent() *Event

GenEvent builds a random Event.

type EventGenerator

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

EventGenerator generates random events.

func NewEventGenerator

func NewEventGenerator(seed int64) *EventGenerator

NewEventGenerator gets a new EventGenerator.

func (*EventGenerator) Event

func (g *EventGenerator) Event() *Event

Event generates a random event.

type Geo

type Geo struct {
	// Low cardinality association.
	TimeZone string `json:"timezone"`

	// Fine grained location.
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

Geo represents a location.

type Interface

type Interface interface {
	// contains filtered or unexported methods
}

Interface exists to make sure that parsing code can handle interface values.

type Item

type Item struct {
	Name  string `json:"name"`
	Value int    `json:"value"`
}

Item has a name and integer value.

type Source

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

Source is a pdk.Source which generates fake Event data.

func NewSource

func NewSource(seed int64, concurrency int, max uint64) *Source

NewSource creates a new Source with the given random seed. Using the same seed should give the same series of events on a given version of Go.

func (*Source) Record

func (s *Source) Record() (interface{}, error)

Record implements pdk.Source and returns a randomly generated fake.Event.

type String

type String string

String wraps string so that it can implement Interface

type User

type User struct {
	ID        uint64
	Age       int
	FirstName string
	LastName  string
	Allergies []string
	Title     string
}

User is a theoretical user type.

type UserGenerator

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

UserGenerator generates fake Users.

func NewUserGenerator

func NewUserGenerator(seed int64) *UserGenerator

NewUserGenerator initializes a new UserGenerator.

func (*UserGenerator) Record

func (u *UserGenerator) Record() *User

Record returns a random User record with realistic-ish values.

type UserSource

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

UserSource is a pdk.Source which generates fake user data.

func NewUserSource

func NewUserSource(seed int64, max uint64) *UserSource

NewUserSource creates a new Source with the given random seed. Using the same seed should give the same series of events on a given version of Go.

func (*UserSource) Record

func (s *UserSource) Record() (interface{}, error)

Record implements pdk.Source and returns a randomly generated user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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