control

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control holds the knobs of the mocks per tenant, for the slots of the benchmark.

Slots share one mock-1c and one mock-wms and tell their rows apart by tenant id. A knob set for a tenant (POST /control with a tenant_id) applies only to the requests of that tenant and wins over the process-wide value from the environment; DELETE /control/{tenant_id} puts the tenant back. Only the stand's own addresses (loopback and private networks) may call the routes.

Input: JSON {"tenant_id": "...", "fail_after_commit_rate": 0..1, "latency_ms": n, "reject_ref_prefix": "...", "ship_qty_factor": "1.5"}; every knob is optional, a missing one is left as it was. Output: the knobs of the tenant as JSON, with the same names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Knobs

type Knobs struct {
	FailAfterCommitRate *float64 `json:"fail_after_commit_rate,omitempty"`
	LatencyMS           *int     `json:"latency_ms,omitempty"`
	RejectRefPrefix     *string  `json:"reject_ref_prefix,omitempty"`
	ShipQtyFactor       *string  `json:"ship_qty_factor,omitempty"`
}

Knobs are the optional overrides of one tenant. A nil field means "not overridden".

func (Knobs) Factor

func (k Knobs) Factor(def string) string

Factor returns the shipped-quantity factor for a tenant, or def when not overridden.

func (Knobs) Latency

func (k Knobs) Latency(def time.Duration) time.Duration

Latency returns the delay for a tenant, or def when not overridden.

func (Knobs) Prefix

func (k Knobs) Prefix(def string) string

Prefix returns the refused reference prefix for a tenant, or def when not overridden.

func (Knobs) Rate

func (k Knobs) Rate(def float64) float64

Rate returns the failure share for a tenant, or def when not overridden.

type Store

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

Store keeps the knobs of the tenants. The zero value is not usable; call New.

func New

func New(allowShipFactor bool) *Store

New builds a store. allowShipFactor enables ship_qty_factor (mock-wms).

func (*Store) Get

func (s *Store) Get(tenant string) Knobs

Get returns the overrides of a tenant (all nil if none).

func (*Store) Register

func (s *Store) Register(mux *http.ServeMux)

Register adds the routes /control and /control/{tenant_id} to a mux.

Jump to

Keyboard shortcuts

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