converter

package
v0.0.0-...-bed98c6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCsvAdapterConfiguration = errors.New("[CSV] invalid adapter configuration")
	ErrInvalidFilePath                = errors.New("[CSV] invalid file path")
	ErrInvalidRetention               = errors.New("[CSV] invalid retention type")
)
View Source
var ErrInvalidMySQLAdapterConfiguration = errors.New("[MySQL] invalid adapter configuration")
View Source
var ErrInvalidUDPAdapterConfiguration = errors.New("[UDP] invalid adapter configuration")

Functions

func SetupAdapter

func SetupAdapter(game enums.Game) []telemetry.ConverterInterface

SetupAdapter sets up game adapters like CSV export, MySQL export, etc.

Types

type BestLapEntity

type BestLapEntity struct {
	ID                  int64     `db:"id"`
	UserID              int64     `db:"user_id"`
	CarOrdinal          int       `db:"CarOrdinal"`
	TrackOrdinal        int       `db:"TrackOrdinal"`
	BestLap             float32   `db:"BestLap"`
	Fuel                float32   `db:"Fuel"`
	CarClass            int       `db:"CarClass"`
	DrivetrainType      int       `db:"DrivetrainType"`
	CarPerformanceIndex int       `db:"CarPerformanceIndex"`
	NumCylinders        int       `db:"NumCylinders"`
	LapNumber           int       `db:"LapNumber"`
	RacePosition        int       `db:"RacePosition"`
	CreatedAt           time.Time `db:"created_at"`
}

type ConverterData

type ConverterData struct {
	GameName enums.Game
}

type ConverterInterface

type ConverterInterface interface {
	ChannelInit(now time.Time, channel chan telemetry.GameData, port int)
	Convert(now time.Time, data telemetry.GameData, port int)
}

type CsvConverter

type CsvConverter struct {
	ConverterData
	Fs        afero.Fs
	FilePath  string
	Retention enums.RetentionType
	// contains filtered or unexported fields
}

func NewCsvConverter

func NewCsvConverter(game enums.Game, adapterConfiguration []string, fs afero.Fs) (*CsvConverter, error)

func (*CsvConverter) ChannelInit

func (csv *CsvConverter) ChannelInit(now time.Time, channel chan telemetry.GameData, port int)

func (*CsvConverter) Convert

func (csv *CsvConverter) Convert(now time.Time, data telemetry.GameData, _ int)

Convert the data to CSV format and writes it to the file

func (*CsvConverter) CorrectFilePath

func (csv *CsvConverter) CorrectFilePath(now time.Time) (string, error)

CorrectFilePath returns the correct file path based on the retention type

type MySQLConverter

type MySQLConverter struct {
	ConverterData
	User, Password, Host, Port, Database, TableName string
	// contains filtered or unexported fields
}

func NewMySQLConverter

func NewMySQLConverter(game enums.Game, adapterConfiguration []string) (*MySQLConverter, error)

func (*MySQLConverter) ChannelInit

func (db *MySQLConverter) ChannelInit(now time.Time, channel chan telemetry.GameData, port int)

func (*MySQLConverter) Convert

func (db *MySQLConverter) Convert(_ time.Time, data telemetry.GameData, _ int)

Convert converts the data to the MySQL database

type MysqlBestLapConverter

type MysqlBestLapConverter struct {
	ConverterData
	User, Password, Host, Port, Database, TableName string
	// contains filtered or unexported fields
}

func NewMysqlBestLapConverter

func NewMysqlBestLapConverter(game enums.Game, adapterConfiguration []string) (*MysqlBestLapConverter, error)

func (*MysqlBestLapConverter) ChannelInit

func (db *MysqlBestLapConverter) ChannelInit(now time.Time, channel chan telemetry.GameData, port int)

func (*MysqlBestLapConverter) Convert

func (db *MysqlBestLapConverter) Convert(_ time.Time, data telemetry.GameData, port int)

Convert converts the data to the MySQL database

type UdpClient

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

type UdpForwarder

type UdpForwarder struct {
	ConverterData
	Clients []*UdpClient
}

func NewUdpForwarder

func NewUdpForwarder(game enums.Game, adapterConfiguration []string) (*UdpForwarder, error)

func (*UdpForwarder) ChannelInit

func (udp *UdpForwarder) ChannelInit(now time.Time, channel chan telemetry.GameData, port int)

func (*UdpForwarder) Convert

func (udp *UdpForwarder) Convert(_ time.Time, data telemetry.GameData, _ int)

Convert converts the data to the UDP clients

Jump to

Keyboard shortcuts

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