Documentation ¶
Index ¶
- type Component
- func (c *Component[T]) GetReader(id string) T
- func (c *Component[T]) GetWriter(id string) T
- func (c *Component[T]) NewReader(id string, items ...T)
- func (c *Component[T]) NewWriter(id string, items ...T)
- func (c *Component[T]) SetReaderBalance(f func(ts ...IInstance[T]) IInstance[T])
- func (c *Component[T]) SetWriterBalance(f func(ts ...IInstance[T]) IInstance[T])
- type IComponent
- type IInstance
- type IItem
- type Instance
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]) SetReaderBalance ¶
func (*Component[T]) SetWriterBalance ¶
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 GetName() string GetWeight() float64 GetValue() T }
IInstance
func NewInstance ¶
Click to show internal directories.
Click to hide internal directories.