simulator

package
v0.0.0-...-0bba01a Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSchema

func GetSchema(eventType string) (*schema.SchemaHandler, error)

Types

type BaseEvent

type BaseEvent struct {
	Timestamp    int64  `json:"timestamp" parquet:"name=timestamp,type=INT64"`
	EventType    string `json:"eventType" parquet:"name=eventType,type=BYTE_ARRAY,convertedtype=UTF8"`
	UserID       string `json:"userId,omitempty" parquet:"name=userId,type=BYTE_ARRAY,convertedtype=UTF8"`
	RestaurantID string `json:"restaurantId,omitempty" parquet:"name=restaurantId,type=BYTE_ARRAY,convertedtype=UTF8"`
	DeliveryID   string `json:"deliveryPartnerId,omitempty" parquet:"name=deliveryPartnerId,type=BYTE_ARRAY,convertedtype=UTF8"`
}

BaseEvent is the common structure for all events

func NewBaseEvent

func NewBaseEvent(eventType string, timestamp time.Time) BaseEvent

type CSVOutput

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

func NewCSVOutput

func NewCSVOutput(basePath, folder string) *CSVOutput

func (*CSVOutput) Close

func (c *CSVOutput) Close() error

func (*CSVOutput) WriteMessage

func (c *CSVOutput) WriteMessage(topic string, msg []byte) error

type CloudParquetFile

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

func NewCloudParquetFile

func NewCloudParquetFile(cloudWriter cloudwriter.CloudWriter) *CloudParquetFile

func (*CloudParquetFile) Close

func (c *CloudParquetFile) Close() error

func (*CloudParquetFile) Create

func (c *CloudParquetFile) Create(name string) (source.ParquetFile, error)

func (*CloudParquetFile) Open

func (c *CloudParquetFile) Open(name string) (source.ParquetFile, error)

func (*CloudParquetFile) Read

func (c *CloudParquetFile) Read(p []byte) (n int, err error)

func (*CloudParquetFile) Seek

func (c *CloudParquetFile) Seek(offset int64, whence int) (int64, error)

func (*CloudParquetFile) Write

func (c *CloudParquetFile) Write(p []byte) (n int, err error)

type ConsoleOutput

type ConsoleOutput struct{}

func (*ConsoleOutput) Close

func (c *ConsoleOutput) Close() error

func (*ConsoleOutput) WriteMessage

func (c *ConsoleOutput) WriteMessage(topic string, msg []byte) error

type DeliveryPartnerAssignmentEvent

type DeliveryPartnerAssignmentEvent struct {
	BaseEvent
	OrderID             string    `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status              string    `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	EstimatedPickupTime time.Time `json:"estimatedPickupTime" parquet:"name=estimatedPickupTime,type=INT64"`
}

DeliveryPartnerAssignmentEvent represents a delivery partner being assigned to an order

type DeliveryPerformanceEvent

type DeliveryPerformanceEvent struct {
	ID                string           `json:"id"`
	DeliveryPartnerID string           `json:"delivery_partner_id"`
	OrderID           string           `json:"order_id"`
	Timestamp         time.Time        `json:"timestamp"`
	EventType         string           `json:"event_type"`
	CurrentLocation   models.Location  `json:"current_location"`
	NewLocation       *models.Location `json:"new_location,omitempty"`
	EstimatedArrival  time.Time        `json:"estimated_arrival"`
	ActualArrival     time.Time        `json:"actual_arrival"`
	Speed             float64          `json:"speed"`
	DistanceCovered   float64          `json:"distance_covered"`
	Status            string           `json:"status"`
	UpdateTime        time.Time        `json:"update_time"`
	CurrentOrder      string           `json:"current_order"`
}

type DeliveryStatusCheckEvent

type DeliveryStatusCheckEvent struct {
	BaseEvent
	OrderID               string          `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status                string          `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	EstimatedDeliveryTime time.Time       `json:"estimatedDeliveryTime" parquet:"name=estimatedDeliveryTime,type=INT64"`
	CurrentLocation       models.Location `json:"currentLocation" parquet:"name=currentLocation,type=STRUCT"`
	NextCheckTime         time.Time       `json:"nextCheckTime" parquet:"name=nextCheckTime,type=INT64"`
}

DeliveryStatusCheckEvent represents a check on the delivery status

type JSONOutput

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

func NewJSONOutput

func NewJSONOutput(basePath, folder string) *JSONOutput

func (*JSONOutput) Close

func (j *JSONOutput) Close() error

func (*JSONOutput) WriteMessage

func (j *JSONOutput) WriteMessage(topic string, msg []byte) error

type KafkaOutput

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

func (*KafkaOutput) WriteMessage

func (k *KafkaOutput) WriteMessage(topic string, msg []byte) error

type OrderCancellationEvent

type OrderCancellationEvent struct {
	BaseEvent
	OrderID          string `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status           string `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	CancellationTime int64  `json:"cancellationTime" parquet:"name=cancellationTime,type=INT64"`
}

OrderCancellationEvent represents an order being cancelled

type OrderDeliveryEvent

type OrderDeliveryEvent struct {
	BaseEvent
	OrderID               string `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status                string `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	EstimatedDeliveryTime int64  `json:"estimatedDeliveryTime" parquet:"name=estimatedDeliveryTime,type=INT64"`
	ActualDeliveryTime    int64  `json:"actualDeliveryTime" parquet:"name=actualDeliveryTime,type=INT64"`
}

OrderDeliveryEvent represents an order being delivered

type OrderInTransitEvent

type OrderInTransitEvent struct {
	BaseEvent
	OrderID               string          `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	DeliveryPartnerID     string          `json:"deliveryPartnerId" parquet:"name=deliveryPartnerId,type=BYTE_ARRAY,convertedtype=UTF8"`
	CustomerID            string          `json:"customerId" parquet:"name=customerId,type=BYTE_ARRAY,convertedtype=UTF8"`
	CurrentLocation       models.Location `json:"currentLocation" parquet:"name=currentLocation,type=STRUCT"`
	EstimatedDeliveryTime time.Time       `json:"estimatedDeliveryTime" parquet:"name=estimatedDeliveryTime,type=INT64"`
	PickupTime            time.Time       `json:"pickupTime" parquet:"name=pickupTime,type=INT64"`
	Status                string          `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
}

OrderInTransitEvent represents an order being in transit

type OrderPickupEvent

type OrderPickupEvent struct {
	BaseEvent
	OrderID               string    `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status                string    `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	PickupTime            time.Time `json:"pickupTime" parquet:"name=pickupTime,type=INT64"`
	EstimatedDeliveryTime time.Time `json:"estimatedDeliveryTime" parquet:"name=estimatedDeliveryTime,type=INT64"`
}

OrderPickupEvent represents an order being picked up by a delivery partner

type OrderPlacedEvent

type OrderPlacedEvent struct {
	BaseEvent
	OrderID         string         `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	ItemIDs         []string       `json:"itemIds" parquet:"name=itemIds,type=BYTE_ARRAY,convertedtype=UTF8"`
	TotalAmount     float64        `json:"totalAmount" parquet:"name=totalAmount,type=DOUBLE"`
	Status          string         `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	OrderPlacedAt   time.Time      `json:"orderPlacedAt" parquet:"name=orderPlacedAt,type=INT64"`
	DeliveryAddress models.Address `json:"deliveryAddress" parquet:"name=newLocation,type=STRUCT"`
}

OrderPlacedEvent represents an order being placed

type OrderPreparationEvent

type OrderPreparationEvent struct {
	BaseEvent
	OrderID         string         `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status          string         `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	PrepStartTime   time.Time      `json:"prepStartTime" parquet:"name=prepStartTime,type=INT64"`
	DeliveryAddress models.Address `json:"deliveryAddress" parquet:"name=newLocation,type=STRUCT"`
}

OrderPreparationEvent represents an order being prepared

type OrderReadyEvent

type OrderReadyEvent struct {
	BaseEvent
	OrderID         string         `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	Status          string         `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=UTF8"`
	PickupTime      time.Time      `json:"pickupTime" parquet:"name=pickupTime,type=INT64"`
	DeliveryAddress models.Address `json:"deliveryAddress" parquet:"name=newLocation,type=STRUCT"`
}

OrderReadyEvent represents an order being ready for pickup

type OutputDestination

type OutputDestination interface {
	WriteMessage(topic string, msg []byte) error
	Close() error
}

type ParquetOutput

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

func NewParquetOutput

func NewParquetOutput(config *models.Config) (*ParquetOutput, error)

func (*ParquetOutput) Close

func (p *ParquetOutput) Close() error

func (*ParquetOutput) WriteMessage

func (p *ParquetOutput) WriteMessage(topic string, msg []byte) error

type PartnerLocationUpdateEvent

type PartnerLocationUpdateEvent struct {
	Timestamp         time.Time       `json:"timestamp" parquet:"name=timestamp,type=INT64"`
	EventType         string          `json:"eventType" parquet:"name=eventType,type=BYTE_ARRAY,convertedtype=BYTE_ARRAY,convertedtype=UTF8"`
	DeliveryPartnerID string          `json:"deliveryPartnerId" parquet:"name=deliveryPartnerId,type=BYTE_ARRAY,convertedtype=BYTE_ARRAY,convertedtype=UTF8"`
	OrderID           string          `` /* 131-byte string literal not displayed */
	NewLocation       models.Location `json:"newLocation" parquet:"name=newLocation,type=STRUCT"`
	CurrentOrder      string          `` /* 141-byte string literal not displayed */
	Status            string          `json:"status" parquet:"name=status,type=BYTE_ARRAY,convertedtype=BYTE_ARRAY,convertedtype=UTF8"`
	UpdateTime        time.Time       `json:"updateTime" parquet:"name=updateTime,type=INT64"`
	Speed             float64         `json:"speed,omitempty" parquet:"name=speed,type=DOUBLE,repetitiontype=OPTIONAL"`
}

PartnerLocationUpdateEvent represents an update to a delivery partner's location

type RestaurantPerformanceEvent

type RestaurantPerformanceEvent struct {
	ID              string    `json:"id"`
	RestaurantID    string    `json:"restaurant_id"`
	Timestamp       time.Time `json:"timestamp"`
	EventType       string    `json:"event_type"`
	CurrentCapacity int       `json:"current_capacity"`
	Capacity        int       `json:"capacity"`
	OrdersInQueue   int       `json:"orders_in_queue"`
	PrepTime        float64   `json:"prep_time"`
	AvgPrepTime     float64   `json:"avg_prep_time"`
	CurrentLoad     float64   `json:"current_load"`
	EfficiencyScore float64   `json:"efficiency_score"`
	CreatedAt       time.Time `json:"created_at"`
}

type RestaurantStatusUpdateEvent

type RestaurantStatusUpdateEvent struct {
	BaseEvent
	Capacity        int32   `json:"capacity" parquet:"name=capacity,type=INT32"`
	CurrentCapacity int32   `json:"current_capacity" parquet:"name=current_capacity,type=INT32"`
	OrdersInQueue   int32   `json:"orders_in_queue" parquet:"name=orders_in_queue,type=INT32"`
	PrepTime        float64 `json:"prep_time" parquet:"name=prep_time,type=DOUBLE"`
}

RestaurantStatusUpdateEvent represents an update to a restaurant's status

type ReviewEvent

type ReviewEvent struct {
	BaseEvent
	ReviewID          string    `json:"reviewId" parquet:"name=reviewId,type=BYTE_ARRAY,convertedtype=UTF8"`
	OrderID           string    `json:"orderId" parquet:"name=orderId,type=BYTE_ARRAY,convertedtype=UTF8"`
	CustomerID        string    `json:"customerId" parquet:"name=customerId,type=BYTE_ARRAY,convertedtype=UTF8"`
	DeliveryPartnerID string    `json:"deliveryPartnerId" parquet:"name=deliveryPartnerId,type=BYTE_ARRAY,convertedtype=UTF8"`
	FoodRating        float64   `json:"foodRating" parquet:"name=foodRating,type=DOUBLE"`
	DeliveryRating    float64   `json:"deliveryRating" parquet:"name=deliveryRating,type=DOUBLE"`
	OverallRating     float64   `json:"overallRating" parquet:"name=overallRating,type=DOUBLE"`
	Comment           string    `json:"comment" parquet:"name=comment,type=BYTE_ARRAY,convertedtype=UTF8"`
	CreatedAt         time.Time `json:"createdAt" parquet:"name=createdAt,type=INT64"`
	OrderTotal        float64   `json:"orderTotal" parquet:"name=orderTotal,type=DOUBLE"`
	DeliveryTime      int64     `json:"deliveryTime" parquet:"name=deliveryTime,type=INT64"`
}

ReviewEvent represents a review being generated

type Simulator

type Simulator struct {
	Config                      *models.Config
	Users                       []*models.User
	DeliveryPartners            []*models.DeliveryPartner
	TrafficConditions           []models.TrafficCondition
	Orders                      []models.Order
	Reviews                     []models.Review
	OrdersByUser                map[string][]models.Order
	CompletedOrdersByRestaurant map[string][]models.Order
	Restaurants                 map[string]*models.Restaurant
	MenuItems                   map[string]*models.MenuItem
	CurrentTime                 time.Time
	Rng                         *rand.Rand
	EventQueue                  *models.EventQueue
}

func NewSimulator

func NewSimulator(config *models.Config) *Simulator

func (*Simulator) Run

func (s *Simulator) Run()

type UserBehaviourUpdateEvent

type UserBehaviourUpdateEvent struct {
	Timestamp      *int64   `json:"timestamp" parquet:"name=timestamp,type=INT64,repetitiontype=OPTIONAL"`
	EventType      *string  `json:"eventType" parquet:"name=eventType,type=BYTE_ARRAY,convertedtype=BYTE_ARRAY,convertedtype=UTF8,repetitiontype=OPTIONAL"`
	UserID         *string  `json:"userId" parquet:"name=userId,type=BYTE_ARRAY,convertedtype=BYTE_ARRAY,convertedtype=UTF8,repetitiontype=OPTIONAL"`
	OrderFrequency *float64 `json:"orderFrequency" parquet:"name=orderFrequency,type=DOUBLE,repetitiontype=OPTIONAL"`
	LastOrderTime  *int64   `json:"lastOrderTime,omitempty" parquet:"name=lastOrderTime,type=INT64,repetitiontype=OPTIONAL"`
}

UserBehaviourUpdateEvent represents an update to a user's behaviour

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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