transformers

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CastTypeIndividual = iota
	CastTypeGroup
	CastTypeAny
)
View Source
const (
	ManagementTypeUniversal = iota
	ManagementTypeLocal
	ManagementTypeAny
)
View Source
const (
	MaleGenderName   = "Male"
	FemaleGenderName = "Female"
	AnyGenderName    = "Any"
)
View Source
const (
	RandomFullNameTransformerFullNameMode = iota
	RandomFullNameTransformerFirstNameMode
	RandomFullNameTransformerSurnameMode
)
View Source
const (
	YearTruncateName        = "year"
	MonthTruncateName       = "month"
	DayTruncateName         = "day"
	HourTruncateName        = "hour"
	MinuteTruncateName      = "minute"
	SecondTruncateName      = "second"
	MillisecondTruncateName = "millisecond"
	MicrosecondTruncateName = "microsecond"
	NanosecondTruncateName  = "nanosecond"
)
View Source
const (
	YearTruncateValue = iota + 1
	MonthTruncateValue
	DayTruncateValue
	HourTruncateValue
	MinuteTruncateValue
	SecondTruncateValue
	MillisecondTruncateValue
	MicrosecondTruncateValue
	NanosecondTruncateValue
)
View Source
const TimestampTransformerByteLength = 16

Variables

View Source
var DefaultFirstNamesFemale = []string{}/* 1441 elements not displayed */
View Source
var DefaultFirstNamesMale = []string{}/* 1571 elements not displayed */
View Source
var DefaultLastNames = []string{}/* 473 elements not displayed */
View Source
var DefaultPersonMap = map[string]map[string][]string{
	MaleGenderName: {
		"Title":     DefaultTitlesMale,
		"LastName":  DefaultLastNames,
		"FirstName": DefaultFirstNamesMale,
	},
	FemaleGenderName: {
		"Title":     DefaultTitlesFemale,
		"LastName":  DefaultLastNames,
		"FirstName": DefaultFirstNamesFemale,
	},
}
View Source
var DefaultTitlesFemale = []string{
	"Mrs.", "Ms.", "Miss", "Dr.", "Prof.", "Lady", "Queen", "Princess",
}
View Source
var DefaultTitlesMale = []string{
	"Mr.", "Dr.", "Prof.", "Lord", "King", "Prince",
}
View Source
var (
	ErrWrongLimits = errors.New("wrong limits")
)

Functions

func GetMinAndMaxNumericValueBySetting

func GetMinAndMaxNumericValueBySetting(digitsBeforeDecimal int) (decimal.Decimal, decimal.Decimal, error)

func ModifyMacAddress

func ModifyMacAddress(newMac, original net.HardwareAddr, keepOriginalVendor bool, castType, managementType int) ([]byte, error)

func RandomBytesToHardwareAddr

func RandomBytesToHardwareAddr(originalBytes []byte) (net.HardwareAddr, error)

func Round

func Round(precision int, num float64) float64

Types

type Database

type Database map[string]map[string][]string

type DateTruncater

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

func NewDateTruncater

func NewDateTruncater(truncatePartName string) (*DateTruncater, error)

func (*DateTruncater) Truncate

func (dt *DateTruncater) Truncate(t time.Time) time.Time

type Float64Limiter

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

func NewFloat64Limiter

func NewFloat64Limiter(minValue, maxValue float64, precision int) (*Float64Limiter, error)

func (*Float64Limiter) Limit

func (fl *Float64Limiter) Limit(v float64) float64

type Int64Limiter

type Int64Limiter struct {
	MinValue int64
	MaxValue int64
	// contains filtered or unexported fields
}

func NewInt64Limiter

func NewInt64Limiter(minValue, maxValue int64) (*Int64Limiter, error)

func (*Int64Limiter) Limit

func (l *Int64Limiter) Limit(v uint64) int64

type IpAddress

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

func NewIpAddress

func NewIpAddress(subnet *net.IPNet) (*IpAddress, error)

func (*IpAddress) Generate

func (ip *IpAddress) Generate(original []byte, runtimeSubnet *net.IPNet) (net.IP, error)

func (*IpAddress) GetRequiredGeneratorByteLength

func (ip *IpAddress) GetRequiredGeneratorByteLength() int

func (*IpAddress) SetGenerator

func (ip *IpAddress) SetGenerator(g generators.Generator) error

type MacAddress

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

func NewMacAddress

func NewMacAddress() (*MacAddress, error)

func (*MacAddress) Generate

func (macAddr *MacAddress) Generate(original net.HardwareAddr, keepOriginalVendor bool, castType int, managementType int) (net.HardwareAddr, error)

func (*MacAddress) GetRequiredGeneratorByteLength

func (macAddr *MacAddress) GetRequiredGeneratorByteLength() int

func (*MacAddress) SetGenerator

func (macAddr *MacAddress) SetGenerator(g generators.Generator) error

type MacAddressInfo

type MacAddressInfo struct {
	MacAddress     net.HardwareAddr
	ManagementType int
	CastType       int
}

func ExploreMacAddress

func ExploreMacAddress(macAddress net.HardwareAddr) (*MacAddressInfo, error)

ExploreMacAddress - explore mac address and return info about it

type NameAttrs

type NameAttrs struct {
	FirstName string
	LastName  string
	Gender    string
	Title     string
}

type NoiseFloat64Limiter

type NoiseFloat64Limiter struct {
	MinValue  float64
	MaxValue  float64
	Precision int
}

func NewNoiseFloat64Limiter

func NewNoiseFloat64Limiter(minVal, maxVal float64, precision int) (*NoiseFloat64Limiter, error)

func (*NoiseFloat64Limiter) Limit

func (ni *NoiseFloat64Limiter) Limit(v float64) float64

type NoiseFloat64Transformer

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

func NewNoiseFloat64Transformer

func NewNoiseFloat64Transformer(limiter *NoiseFloat64Limiter, minRatio, maxRatio float64) *NoiseFloat64Transformer

func (*NoiseFloat64Transformer) GetRequiredGeneratorByteLength

func (nt *NoiseFloat64Transformer) GetRequiredGeneratorByteLength() int

func (*NoiseFloat64Transformer) SetGenerator

func (nt *NoiseFloat64Transformer) SetGenerator(g generators.Generator) error

func (*NoiseFloat64Transformer) Transform

func (nt *NoiseFloat64Transformer) Transform(l *NoiseFloat64Limiter, original float64) (float64, error)

type NoiseInt64Limiter

type NoiseInt64Limiter struct {
	MinValue int64
	MaxValue int64
}

func NewNoiseInt64Limiter

func NewNoiseInt64Limiter(minVal, maxVal int64) (*NoiseInt64Limiter, error)

func (*NoiseInt64Limiter) Limit

func (ni *NoiseInt64Limiter) Limit(v int64) int64

type NoiseInt64Transformer

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

func NewNoiseInt64Transformer

func NewNoiseInt64Transformer(limiter *NoiseInt64Limiter, minRatio, maxRatio float64) (*NoiseInt64Transformer, error)

func (*NoiseInt64Transformer) GetRequiredGeneratorByteLength

func (ig *NoiseInt64Transformer) GetRequiredGeneratorByteLength() int

func (*NoiseInt64Transformer) SetGenerator

func (ig *NoiseInt64Transformer) SetGenerator(g generators.Generator) error

func (*NoiseInt64Transformer) Transform

func (ig *NoiseInt64Transformer) Transform(l *NoiseInt64Limiter, original int64) (int64, error)

type NoiseNumericLimiter

type NoiseNumericLimiter struct {
	MinValue decimal.Decimal
	MaxValue decimal.Decimal
	// contains filtered or unexported fields
}

func NewNoiseNumericLimiter

func NewNoiseNumericLimiter(minVal, maxVal decimal.Decimal) (*NoiseNumericLimiter, error)

func (*NoiseNumericLimiter) Limit

func (*NoiseNumericLimiter) SetPrecision

func (ni *NoiseNumericLimiter) SetPrecision(v int32) *NoiseNumericLimiter

type NoiseNumericTransformer

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

func NewNoiseNumericTransformer

func NewNoiseNumericTransformer(limiter *NoiseNumericLimiter, minRatio, maxRatio float64) *NoiseNumericTransformer

func (*NoiseNumericTransformer) GetRequiredGeneratorByteLength

func (nt *NoiseNumericTransformer) GetRequiredGeneratorByteLength() int

func (*NoiseNumericTransformer) SetDynamicLimiter

SetDynamicLimiter sets the limiter for the dynamic mode. dynamicLimiter will be used set as nil after the Transform call.

func (*NoiseNumericTransformer) SetGenerator

func (nt *NoiseNumericTransformer) SetGenerator(g generators.Generator) error

func (*NoiseNumericTransformer) Transform

func (nt *NoiseNumericTransformer) Transform(original decimal.Decimal) (decimal.Decimal, error)

type NoiseTimestamp

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

func NewNoiseTimestamp

func NewNoiseTimestamp(minRatio, maxRatio time.Duration, truncatePart string, limiter *NoiseTimestampLimiter) (*NoiseTimestamp, error)

func (*NoiseTimestamp) GetRequiredGeneratorByteLength

func (d *NoiseTimestamp) GetRequiredGeneratorByteLength() int

func (*NoiseTimestamp) SetGenerator

func (d *NoiseTimestamp) SetGenerator(g generators.Generator) error

func (*NoiseTimestamp) Transform

func (d *NoiseTimestamp) Transform(l *NoiseTimestampLimiter, v time.Time) (time.Time, error)

type NoiseTimestampLimiter

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

func NewNoiseTimestampLimiter

func NewNoiseTimestampLimiter(minDate, maxDate *time.Time) (*NoiseTimestampLimiter, error)

func (*NoiseTimestampLimiter) Limit

func (ntl *NoiseTimestampLimiter) Limit(v time.Time) time.Time

type PersonDatabase

type PersonDatabase struct {
	Db              Database
	Genders         []string
	Attributes      []string
	AttributesCount int
}

func NewPersonalDatabase

func NewPersonalDatabase(data Database) *PersonDatabase

func (*PersonDatabase) GetRandomAttribute

func (pd *PersonDatabase) GetRandomAttribute(gender, attr string, randomIdx uint32) string

func (*PersonDatabase) GetRandomGender

func (pd *PersonDatabase) GetRandomGender(randomIdx uint32) string

type RandomBoolean

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

func NewRandomBoolean

func NewRandomBoolean() *RandomBoolean

func (*RandomBoolean) GetRequiredGeneratorByteLength

func (b *RandomBoolean) GetRequiredGeneratorByteLength() int

func (*RandomBoolean) SetGenerator

func (b *RandomBoolean) SetGenerator(g generators.Generator) error

func (*RandomBoolean) Transform

func (b *RandomBoolean) Transform(original []byte) (bool, error)

type RandomChoiceTransformer

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

func NewRandomChoiceTransformer

func NewRandomChoiceTransformer(values []*toolkit.RawValue) *RandomChoiceTransformer

func (*RandomChoiceTransformer) GetRequiredGeneratorByteLength

func (rc *RandomChoiceTransformer) GetRequiredGeneratorByteLength() int

func (*RandomChoiceTransformer) SetGenerator

func (rc *RandomChoiceTransformer) SetGenerator(g generators.Generator) error

func (*RandomChoiceTransformer) Transform

func (rc *RandomChoiceTransformer) Transform(original []byte) (*toolkit.RawValue, error)

type RandomFloat64Transformer

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

func NewRandomFloat64Transformer

func NewRandomFloat64Transformer(limiter *Float64Limiter) *RandomFloat64Transformer

func (*RandomFloat64Transformer) GetRequiredGeneratorByteLength

func (f *RandomFloat64Transformer) GetRequiredGeneratorByteLength() int

func (*RandomFloat64Transformer) SetGenerator

func (*RandomFloat64Transformer) Transform

func (f *RandomFloat64Transformer) Transform(l *Float64Limiter, original []byte) (float64, error)

type RandomInt64Transformer

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

func NewRandomInt64Transformer

func NewRandomInt64Transformer(limiter *Int64Limiter, size int) (*RandomInt64Transformer, error)

func (*RandomInt64Transformer) GetRequiredGeneratorByteLength

func (ig *RandomInt64Transformer) GetRequiredGeneratorByteLength() int

func (*RandomInt64Transformer) SetGenerator

func (ig *RandomInt64Transformer) SetGenerator(g generators.Generator) error

func (*RandomInt64Transformer) Transform

func (ig *RandomInt64Transformer) Transform(l *Int64Limiter, original []byte) (int64, error)

type RandomNumericLimiter

type RandomNumericLimiter struct {
	MinValue decimal.Decimal
	MaxValue decimal.Decimal
	// contains filtered or unexported fields
}

func NewRandomNumericLimiter

func NewRandomNumericLimiter(minValue, maxValue decimal.Decimal) (*RandomNumericLimiter, error)

func NewRandomNumericLimiterFromSize

func NewRandomNumericLimiterFromSize(digitsBeforeDecimal int) (*RandomNumericLimiter, error)

func (*RandomNumericLimiter) ByteLength

func (l *RandomNumericLimiter) ByteLength() int

func (*RandomNumericLimiter) Limit

func (*RandomNumericLimiter) SetPrecision

func (l *RandomNumericLimiter) SetPrecision(v int32)

type RandomNumericTransformer

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

func NewRandomNumericTransformer

func NewRandomNumericTransformer(limiter *RandomNumericLimiter, precision int32) (*RandomNumericTransformer, error)

func (*RandomNumericTransformer) GetRequiredGeneratorByteLength

func (ig *RandomNumericTransformer) GetRequiredGeneratorByteLength() int

func (*RandomNumericTransformer) SetDynamicLimiter

SetDynamicLimiter sets the limiter for the dynamic mode. dynamicLimiter will be used set as nil after the Transform call.

func (*RandomNumericTransformer) SetGenerator

func (ig *RandomNumericTransformer) SetGenerator(g generators.Generator) error

func (*RandomNumericTransformer) Transform

func (ig *RandomNumericTransformer) Transform(original []byte) (decimal.Decimal, error)

type RandomPersonTransformer

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

func NewRandomPersonTransformer

func NewRandomPersonTransformer(gender string, personDb Database) *RandomPersonTransformer

func (*RandomPersonTransformer) GetDb

func (*RandomPersonTransformer) GetFullName

func (rpt *RandomPersonTransformer) GetFullName(gender string, original []byte) (map[string]string, error)

func (*RandomPersonTransformer) GetRequiredGeneratorByteLength

func (rpt *RandomPersonTransformer) GetRequiredGeneratorByteLength() int

func (*RandomPersonTransformer) SetGenerator

func (rpt *RandomPersonTransformer) SetGenerator(g generators.Generator) error

type RandomStringTransformer

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

func NewRandomStringTransformer

func NewRandomStringTransformer(chars []rune, minLength, maxLength int) (*RandomStringTransformer, error)

func (*RandomStringTransformer) GetRequiredGeneratorByteLength

func (st *RandomStringTransformer) GetRequiredGeneratorByteLength() int

func (*RandomStringTransformer) SetGenerator

func (st *RandomStringTransformer) SetGenerator(g generators.Generator) error

func (*RandomStringTransformer) Transform

func (st *RandomStringTransformer) Transform(data []byte) []rune

type RandomUuidTransformer

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

func NewRandomUuidTransformer

func NewRandomUuidTransformer() *RandomUuidTransformer

func (*RandomUuidTransformer) GetRequiredGeneratorByteLength

func (ut *RandomUuidTransformer) GetRequiredGeneratorByteLength() int

func (*RandomUuidTransformer) SetGenerator

func (ut *RandomUuidTransformer) SetGenerator(g generators.Generator) error

func (*RandomUuidTransformer) Transform

func (ut *RandomUuidTransformer) Transform(data []byte) (uuid.UUID, error)

type Timestamp

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

func NewRandomTimestamp

func NewRandomTimestamp(truncatePart string, limiter *TimestampLimiter) (*Timestamp, error)

func (*Timestamp) GetRequiredGeneratorByteLength

func (d *Timestamp) GetRequiredGeneratorByteLength() int

func (*Timestamp) SetGenerator

func (d *Timestamp) SetGenerator(g generators.Generator) error

func (*Timestamp) Transform

func (d *Timestamp) Transform(l *TimestampLimiter, data []byte) (time.Time, error)

type TimestampLimiter

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

func NewTimestampLimiter

func NewTimestampLimiter(minDate, maxDate time.Time) (*TimestampLimiter, error)

func (*TimestampLimiter) Limit

func (dl *TimestampLimiter) Limit(sec, nano int64) (int64, int64)

type Transformer

type Transformer interface {
	GetRequiredGeneratorByteLength() int
	SetGenerator(g generators.Generator) error
}

Jump to

Keyboard shortcuts

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