seed

package
v0.0.0-...-4c8d4de Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type CountSeed

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

A CountSeed allows the drill of seeds that keep an inner counter at time of writing only the basic prop++ counter is defined **Props type accepted: int

any other type is ignored

func NewCountSeed

func NewCountSeed(base any, start int) *CountSeed

func (*CountSeed) GetMeta

func (s *CountSeed) GetMeta() *SeedMeta

func (*CountSeed) GetProps

func (s *CountSeed) GetProps() []string

func (*CountSeed) GetSize

func (s *CountSeed) GetSize() int

GetSize must return -1 for infinite seeds

func (*CountSeed) ReadOne

func (s *CountSeed) ReadOne() []prop

type NameIndex

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

Tuple for prop and field indexes, used by names map to get field or prop directly

type Seed

type Seed interface {

	// Get seed props
	GetProps() []string

	// Filter seed props, use in conjunction with GetProps to update them
	WithProps([]string) int

	// These methods returns seeds ready to drill
	// Method to return a single seed
	ReadOne() []prop

	// Method to return an specified amount of seeds
	ReadMany(int) []any

	// Method to return all seeds, only 1 if no limit is configured
	ReadAll() []any

	// This method gets the size of the seed source, -1 if unlimited
	GetSize() int

	// This method gets the metadata of the seed, forces SeedMeta usage
	GetMeta() *SeedMeta
}

The Seed interface allows the implementation of Seeds a Seed is the concept of a crop source, the seed must provide the availity to load data, keep internal state and refresh state. ... Each seed configures a inner struct of type Any, this struct is used to configure the data that is retrieved, since the struct fields are not known in advance, the seed must include logic to handle a proper usage of the struct

type SeedMeta

type SeedMeta struct {

	// Seed name
	Name string

	// Seed props
	Props []prop

	// Seed names
	Names map[string]NameIndex

	// Seed struct
	Struct reflect.Value
}

Seeds metadata to perform operations on data and keep state of it

func ObtainProps

func ObtainProps(base any, name string, types ...reflect.Kind) SeedMeta

An utility function to get the props of a struct of type any, allows seed implementations to follow the same guideline when setting up the initialization of the inner struct

func (*SeedMeta) GetField

func (s *SeedMeta) GetField(name string) reflect.Value

Jump to

Keyboard shortcuts

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