embedded

package
v0.0.0-...-70ec780 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component[T IItem] struct {
	Writers       map[string][]IInstance[T]             // 写节点
	WriterBalance func(ts ...IInstance[T]) IInstance[T] // 选取算法
	Readers       map[string][]IInstance[T]             // 读节点
	ReaderBalance func(ts ...IInstance[T]) IInstance[T] //选取算法
}

func (*Component[T]) GetReader

func (c *Component[T]) GetReader(id string) T

func (*Component[T]) GetWriter

func (c *Component[T]) GetWriter(id string) T

func (*Component[T]) NewReader

func (c *Component[T]) NewReader(id string, items ...T)

func (*Component[T]) NewWriter

func (c *Component[T]) NewWriter(id string, items ...T)

func (*Component[T]) SetReaderBalance

func (c *Component[T]) SetReaderBalance(f func(ts ...IInstance[T]) IInstance[T])

func (*Component[T]) SetWriterBalance

func (c *Component[T]) SetWriterBalance(f func(ts ...IInstance[T]) IInstance[T])

type IComponent

type IComponent[T IItem] interface {
	NewWriter(id string, items ...T)
	GetWriter(id string) T
	NewReader(id string, items ...T)
	GetReader(id string) T
	SetWriterBalance(f func(ts ...IInstance[T]) IInstance[T])
	SetReaderBalance(f func(ts ...IInstance[T]) IInstance[T])
}

IComponent

func NewComponent

func NewComponent[T IItem]() IComponent[T]

type IInstance

type IInstance[T IItem] interface {
	GetID() string
	GetWeight() float64
	GetValue() T
}

IInstance

func NewInstance

func NewInstance[T IItem](id string, item T) IInstance[T]

type IItem

type IItem any // client or sdk

type Instance

type Instance[T IItem] struct {
	Id     string
	Weight float64
	Value  T
}

func (*Instance[T]) GetID

func (c *Instance[T]) GetID() string

func (*Instance[T]) GetValue

func (c *Instance[T]) GetValue() T

func (*Instance[T]) GetWeight

func (c *Instance[T]) GetWeight() float64

Jump to

Keyboard shortcuts

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