Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HistoryToString ¶
func HistoryToString(history []historyDescription) string
Types ¶
type KV ¶
type KV struct { Key string `bson:"_id"` Document interface{} `bson:"document"` }
KV is Key-Document object for key-value database (Mongo or in-memory)
func GenerateKV ¶
GenerateKV produces random Key-Document object with key and value as string of `keysize` and `valsize` length respectfully
type RpsCallbacks ¶
type RpsCallbacks struct { Tick func(ctx context.Context, index int, rps *RpsModel) bool OnDelete func(ctx context.Context, key string) OnCreate func(ctx context.Context, entity KV) OnUpdate func(ctx context.Context, previous KV, actual KV) OnReplace func(ctx context.Context, previous KV, actual KV) }
RpsNotifier contains callbacks for different events of RPS generator
type RpsModel ¶
type RpsModel struct { // we should uniformly distribute documents between this two categories: Persistent map[string]interface{} // present KV NonPersistent map[string]struct{} // sometimes deleted KV ModelHistory map[string][]historyDescription // contains filtered or unexported fields }
RpsModel is a:
- rate-limiter for requests
- in-mem KV storage
Anyone can access in-memory Persistent state, NonPersistent(deleted) state, and change history as ModelHistory
func NewRpsModel ¶
func NewRpsModel(ctx context.Context, notifiers *RpsCallbacks) *RpsModel
NewRpsModel creates RPS model use initialSpec to set frequency and value of operations use onCreate, onDelete and onUpdate from RpsCallbacks to make actions (e.g. with database) use Delay in RpsCallbacks to reconfigure RPS in time
func (*RpsModel) CheckValid ¶
Click to show internal directories.
Click to hide internal directories.