Documentation
¶
Index ¶
- Constants
- func Clip[T constraints.Ordered](value, low, high T) T
- func CreateConfigTxFromConfigBlock(block *common.Block) (*servicepb.LoadGenTx, error)
- func CreateLoadGenNamespacesTX(policy *PolicyProfile) (*servicepb.LoadGenTx, error)
- func CreateNamespacesTX(policy *PolicyProfile, metaNamespaceVersion uint64, includeNS ...string) (*applicationpb.Tx, error)
- func CreateNamespacesTxFromEndorser(endorser *TxEndorser, metaNamespaceVersion uint64, includeNS ...string) (*applicationpb.Tx, error)
- func CreateOrExtendConfigBlockWithCrypto(policy *PolicyProfile) (*common.Block, error)
- func CreateOrLoadConfigBlockWithCrypto(policy *PolicyProfile) (*common.Block, error)
- func GenerateArray[G Generator[T], T any](g G, size int) []T
- func GenerateTransactions(tb testing.TB, p *Profile, count int) []*servicepb.LoadGenTx
- func Map[T, K any](arr []T, mapper func(index int, value T) K) []K
- func MapToCoordinatorBatch(blockNum uint64, txs []*servicepb.LoadGenTx) *servicepb.CoordinatorBatch
- func MapToEnvelopeBatch(_ uint64, txs []*servicepb.LoadGenTx) []*common.Envelope
- func MapToLoadGenBatch(_ uint64, txs []*servicepb.LoadGenTx) *servicepb.LoadGenBatch
- func MapToOrdererBlock(blockNum uint64, txs []*servicepb.LoadGenTx) *common.Block
- func MapToVcBatch(blockNum uint64, txs []*servicepb.LoadGenTx) *servicepb.VcBatch
- func MapToVerifierBatch(blockNum uint64, txs []*servicepb.LoadGenTx) *servicepb.VerifierBatch
- func MeanStd[T constraints.Float](arr []T) (mean, std float64)
- func Must(err error)
- func NewPolicyEndorserFromMsp(artifactsPath string) (*testsig.NsEndorser, *applicationpb.NamespacePolicy)
- func NewRandFromSeedGenerator(seedRnd *rand.Rand) *rand.Rand
- func Sum[T constraints.Float](arr []T) float64
- func SumInt[T constraints.Integer](arr []T) int64
- type BernoulliGenerator
- type BlockProfile
- type ByteArrayGenerator
- type ConflictProfile
- type ConstGenerator
- type ConsumeParameters
- type ConsumerRateController
- func (l *ConsumerRateController[T]) Consume(ctx context.Context, p ConsumeParameters) []T
- func (l *ConsumerRateController[T]) InstantiateWorker() *ConsumerRateController[T]
- func (l *ConsumerRateController[T]) Next(ctx context.Context) T
- func (l *ConsumerRateController[T]) Rate() uint64
- func (l *ConsumerRateController[T]) SetRate(rate uint64)
- type DependencyDescription
- type DiscreteGenerator
- type DiscreteValue
- type Distribution
- func NewBernoulliDistribution(probability Probability) *Distribution
- func NewConstantDistribution(value float64) *Distribution
- func NewDiscreteDistribution(values []DiscreteValue[float64]) *Distribution
- func NewNormalDistribution(mean, std float64) *Distribution
- func NewUniformDistribution(minVal, maxVal float64) *Distribution
- func (d *Distribution) MakeBooleanGenerator(rnd *rand.Rand) *FloatToBooleanGenerator
- func (d *Distribution) MakeGenerator(rnd *rand.Rand) Generator[float64]
- func (d *Distribution) MakeIntGenerator(rnd *rand.Rand) *FloatToIntGenerator
- func (d *Distribution) MakePositiveIntGenerator(rnd *rand.Rand) *FloatToPositiveIntGenerator
- type FloatToBooleanGenerator
- type FloatToIntGenerator
- type FloatToPositiveIntGenerator
- type Generator
- type IndependentTxGenerator
- type Key
- type KeyPath
- type KeyProfile
- type Modifier
- type MultiGenerator
- type NormalDist
- type NormalGenerator
- type Policy
- type PolicyProfile
- type Probability
- type Profile
- type QueryGenerator
- type QueryProfile
- type QueryStream
- type StreamOptions
- type StreamWithSetup
- type TransactionProfile
- type TxBuilder
- type TxEndorser
- type TxGeneratorWithSetup
- type TxStream
- type UniformDist
- type UniformGenerator
Constants ¶
const ( DependencyReadOnly = "read" DependencyReadWrite = "read-write" DependencyBlindWrite = "write" )
Dependency types.
const DefaultGeneratedNamespaceID = "0"
DefaultGeneratedNamespaceID for now we're only generating transactions for a single namespace.
Variables ¶
This section is empty.
Functions ¶
func Clip ¶
func Clip[T constraints.Ordered](value, low, high T) T
Clip returns the given value, clipped between the given boundaries.
func CreateConfigTxFromConfigBlock ¶ added in v0.1.8
CreateConfigTxFromConfigBlock creates a config TX.
func CreateLoadGenNamespacesTX ¶ added in v0.1.6
func CreateLoadGenNamespacesTX(policy *PolicyProfile) (*servicepb.LoadGenTx, error)
CreateLoadGenNamespacesTX creating the transaction containing the requested namespaces into the MetaNamespace.
func CreateNamespacesTX ¶
func CreateNamespacesTX( policy *PolicyProfile, metaNamespaceVersion uint64, includeNS ...string, ) (*applicationpb.Tx, error)
CreateNamespacesTX creating the transaction containing the requested namespaces into the MetaNamespace.
func CreateNamespacesTxFromEndorser ¶ added in v0.1.8
func CreateNamespacesTxFromEndorser( endorser *TxEndorser, metaNamespaceVersion uint64, includeNS ...string, ) (*applicationpb.Tx, error)
CreateNamespacesTxFromEndorser creating the transaction containing the requested namespaces into the MetaNamespace.
func CreateOrExtendConfigBlockWithCrypto ¶ added in v0.1.9
func CreateOrExtendConfigBlockWithCrypto(policy *PolicyProfile) (*common.Block, error)
CreateOrExtendConfigBlockWithCrypto generates or extends the crypto artifacts for a policy. This will generate a new config block, or overwrite the existing config block if it already exists.
func CreateOrLoadConfigBlockWithCrypto ¶ added in v0.1.9
func CreateOrLoadConfigBlockWithCrypto(policy *PolicyProfile) (*common.Block, error)
CreateOrLoadConfigBlockWithCrypto generates the crypto artifacts for a policy. If it is already generated, it will load the config block from the file system.
func GenerateArray ¶
GenerateArray generates an array of items of the requested size given a generator.
func GenerateTransactions ¶ added in v0.1.4
GenerateTransactions is used for benchmarking.
func MapToCoordinatorBatch ¶ added in v0.1.6
func MapToCoordinatorBatch(blockNum uint64, txs []*servicepb.LoadGenTx) *servicepb.CoordinatorBatch
MapToCoordinatorBatch creates a Coordinator batch.
func MapToEnvelopeBatch ¶ added in v0.1.6
MapToEnvelopeBatch creates a batch of Fabric's Orderer input envelopes.
func MapToLoadGenBatch ¶ added in v0.1.6
func MapToLoadGenBatch(_ uint64, txs []*servicepb.LoadGenTx) *servicepb.LoadGenBatch
MapToLoadGenBatch creates a load-gen batch.
func MapToOrdererBlock ¶ added in v0.1.6
MapToOrdererBlock creates a Fabric's Orderer output block.
func MapToVcBatch ¶ added in v0.1.6
MapToVcBatch creates a VC batch.
func MapToVerifierBatch ¶ added in v0.1.6
func MapToVerifierBatch(blockNum uint64, txs []*servicepb.LoadGenTx) *servicepb.VerifierBatch
MapToVerifierBatch creates a Verifier batch.
func MeanStd ¶
func MeanStd[T constraints.Float](arr []T) (mean, std float64)
MeanStd returns the mean and std of an array of float samples.
func NewPolicyEndorserFromMsp ¶ added in v0.1.9
func NewPolicyEndorserFromMsp(artifactsPath string) (*testsig.NsEndorser, *applicationpb.NamespacePolicy)
NewPolicyEndorserFromMsp creates an MSP-based endorser and namespace policy from the peer organization crypto artifacts under artifactsPath.
func NewRandFromSeedGenerator ¶
NewRandFromSeedGenerator creates a new random generator using a generated seed.
func Sum ¶
func Sum[T constraints.Float](arr []T) float64
Sum returns the sum of an array of floats.
func SumInt ¶
func SumInt[T constraints.Integer](arr []T) int64
SumInt returns the sum of an array of integers.
Types ¶
type BernoulliGenerator ¶
type BernoulliGenerator struct {
Rnd *rand.Rand
Probability Probability
}
BernoulliGenerator generates 1 with probability of p.
func (*BernoulliGenerator) Next ¶
func (d *BernoulliGenerator) Next() float64
Next yields the next bernoulli value.
type BlockProfile ¶
type BlockProfile struct {
MaxSize uint64 `mapstructure:"max-size" yaml:"max-size"`
MinSize uint64 `mapstructure:"min-size" yaml:"min-size"`
PreferredRate time.Duration `mapstructure:"preferred-rate" yaml:"preferred-rate"`
}
BlockProfile describes generate block characteristics (when applying load to the VC or Verifier, blocks are translated to batches). The generated block size is aimed to be MaxSize, if the generated TXs rate is sufficient. If the generated TXs rate is too low, the block size might be less than MaxSize, but at least MinSize. In such case, the block is generated at a preferred rate of PreferredRate. Blocks wait up to PreferredRate (default: 1 second) before submission. If a full block is not ready by then, a partial block is submitted if it meets MinSize (default: 1); otherwise, the system waits until MinSize is available. If the MaxSize is less than or equal to MinSize, PreferredRate is ignored.
type ByteArrayGenerator ¶
ByteArrayGenerator generates a random byte array of Size.
func (*ByteArrayGenerator) Next ¶
func (g *ByteArrayGenerator) Next() []byte
Next yields a byte array.
type ConflictProfile ¶
type ConflictProfile struct {
// Probability of invalid signatures [0,1] (default: 0)
InvalidSignatures Probability `mapstructure:"invalid-signatures" yaml:"invalid-signatures"`
// Dependencies list of dependencies
Dependencies []DependencyDescription `mapstructure:"dependencies" yaml:"dependencies"`
}
ConflictProfile describes the TX conflict characteristics. Note that each of the conflicts' probabilities are independent bernoulli distributions.
type ConstGenerator ¶
type ConstGenerator[T any] struct { Const T }
ConstGenerator produces a constant value.
func (*ConstGenerator[T]) Next ¶
func (g *ConstGenerator[T]) Next() T
Next yields the constant value.
type ConsumeParameters ¶ added in v0.1.8
ConsumeParameters describes the consume request parameters.
type ConsumerRateController ¶ added in v0.1.8
type ConsumerRateController[T any] struct { // contains filtered or unexported fields }
ConsumerRateController controls the consumption rate from a inputQueue while ensuring:
- smooth pacing,
- bounded waiting,
- and useful batch sizes.
It is designed for progress-driven workloads (streaming, chunked processing, UI updates, network sends), where callers prefer some progress within a deadline rather than waiting indefinitely for a full request. The rate controller is based on a token bucket with two additional guarantees: - a maximum wait time for partial delivery, - a minimum batch size for efficiency.
Unlike standard rate limiters, it enforces both a latency deadline and a minimum useful batch, making it suitable for block- and batch-driven systems rather than per-request throttling.
func NewConsumerRateController ¶ added in v0.1.8
func NewConsumerRateController[T any](rate uint64, inputQueue <-chan []T) *ConsumerRateController[T]
NewConsumerRateController create a new rate controller.
func (*ConsumerRateController[T]) Consume ¶ added in v0.1.8
func (l *ConsumerRateController[T]) Consume(ctx context.Context, p ConsumeParameters) []T
Consume requests up to RequestedItems from the producer. The call may block for some time, and may return fewer items than requested depending on MinItems and softTimeout.
The rate controller chooses one of three outcomes:
- Full request (fast path): If RequestedItems can be made available within SoftTimeout, the call waits just long enough and returns exactly the RequestedItems.
- Partial batch (deadline path): If waiting SoftTimeout yields a meaningful amount of items (>= MinItems), the call waits SoftTimeout and returns as many items as are available at that time (less than requested).
- Minimum batch (efficiency path): If even after SoftTimeout fewer than MinItems would be available, the call waits longer until MinItems is ready, then returns exactly MinItems.
Notes:
- If SoftTimeout is not positive, or MinItems is not less than RequestedItems, the call waits indefinitely for RequestedItems.
- If the context is canceled before any items are available, the call returns nil.
- If RequestedItems is less than 1, the call returns nil immediately.
func (*ConsumerRateController[T]) InstantiateWorker ¶ added in v0.1.8
func (l *ConsumerRateController[T]) InstantiateWorker() *ConsumerRateController[T]
InstantiateWorker creates a new rate controller instance that shares the same state and inputQueue. The worker instance maintains its own outputBuffer.
func (*ConsumerRateController[T]) Next ¶ added in v0.1.8
func (l *ConsumerRateController[T]) Next(ctx context.Context) T
Next consumes a single item from the inputQueue.
func (*ConsumerRateController[T]) Rate ¶ added in v0.1.8
func (l *ConsumerRateController[T]) Rate() uint64
Rate returns the current rate limit in tokens per second.
func (*ConsumerRateController[T]) SetRate ¶ added in v0.1.8
func (l *ConsumerRateController[T]) SetRate(rate uint64)
SetRate updates the rate limit to the specified value in tokens per second. It resets the timeline, so any accumulated tokens will be erased.
type DependencyDescription ¶
type DependencyDescription struct {
// Probability of the dependency type [0,1] (default: 0)
Probability Probability `mapstructure:"probability" yaml:"probability"`
// Gap is the distance between the dependent TXs (default: 1)
Gap *Distribution `mapstructure:"gap" yaml:"gap"`
// Src dependency "read", "write", or "read-write"
Src string `mapstructure:"src" yaml:"src"`
// Dst dependency "read", "write", or "read-write"
Dst string `mapstructure:"dst" yaml:"dst"`
}
DependencyDescription describes a dependency type.
type DiscreteGenerator ¶
type DiscreteGenerator[T any] struct { Rnd *rand.Rand Values []DiscreteValue[T] }
DiscreteGenerator generates values with a discrete distribution.
func (*DiscreteGenerator[T]) Next ¶
func (d *DiscreteGenerator[T]) Next() T
Next yields the next discrete value.
type DiscreteValue ¶
type DiscreteValue[T any] struct { Value T `mapstructure:"value"` Probability Probability `mapstructure:"probability"` }
DiscreteValue describe the appearance probability of a value.
type Distribution ¶
type Distribution struct {
Const float64 `mapstructure:"const" yaml:"const,omitempty"`
Uniform *UniformDist `mapstructure:"uniform" yaml:"uniform,omitempty"`
Normal *NormalDist `mapstructure:"normal" yaml:"normal,omitempty"`
Bernoulli Probability `mapstructure:"bernoulli" yaml:"bernoulli,omitempty"`
Discrete []DiscreteValue[float64] `mapstructure:"discrete" yaml:"discrete,omitempty"`
}
Distribution descriptor for the available distributions.
func NewBernoulliDistribution ¶
func NewBernoulliDistribution(probability Probability) *Distribution
NewBernoulliDistribution creates a Bernoulli distribution.
func NewConstantDistribution ¶
func NewConstantDistribution(value float64) *Distribution
NewConstantDistribution creates a constant value distribution.
func NewDiscreteDistribution ¶
func NewDiscreteDistribution(values []DiscreteValue[float64]) *Distribution
NewDiscreteDistribution creates a discrete distribution.
func NewNormalDistribution ¶
func NewNormalDistribution(mean, std float64) *Distribution
NewNormalDistribution creates a normal distribution.
func NewUniformDistribution ¶
func NewUniformDistribution(minVal, maxVal float64) *Distribution
NewUniformDistribution creates a uniform distribution.
func (*Distribution) MakeBooleanGenerator ¶
func (d *Distribution) MakeBooleanGenerator(rnd *rand.Rand) *FloatToBooleanGenerator
MakeBooleanGenerator returns a new boolean generator according to the distribution description.
func (*Distribution) MakeGenerator ¶
func (d *Distribution) MakeGenerator(rnd *rand.Rand) Generator[float64]
MakeGenerator returns a new generator according to the distribution description. The default distribution is const=0.
func (*Distribution) MakeIntGenerator ¶
func (d *Distribution) MakeIntGenerator(rnd *rand.Rand) *FloatToIntGenerator
MakeIntGenerator returns a new integer generator according to the distribution description.
func (*Distribution) MakePositiveIntGenerator ¶
func (d *Distribution) MakePositiveIntGenerator(rnd *rand.Rand) *FloatToPositiveIntGenerator
MakePositiveIntGenerator returns a new positive (>=1) integer generator according to the distribution description.
type FloatToBooleanGenerator ¶
FloatToBooleanGenerator wraps a float generator and produces boolean (true when >=1).
func (*FloatToBooleanGenerator) Next ¶
func (g *FloatToBooleanGenerator) Next() bool
Next yields a new integer.
type FloatToIntGenerator ¶
FloatToIntGenerator wraps a float generator and produces integers.
func (*FloatToIntGenerator) Next ¶
func (g *FloatToIntGenerator) Next() int
Next yields a new integer.
type FloatToPositiveIntGenerator ¶
FloatToPositiveIntGenerator wraps a float generator and produces positive int (>=1).
func (*FloatToPositiveIntGenerator) Next ¶
func (g *FloatToPositiveIntGenerator) Next() uint64
Next yields a new integer.
type Generator ¶
type Generator[T any] interface { Next() T }
Generator generates new T each time Next() is called.
type IndependentTxGenerator ¶
type IndependentTxGenerator struct {
TxBuilder *TxBuilder
ReadOnlyKeyGenerator *MultiGenerator[Key]
ReadWriteKeyGenerator *MultiGenerator[Key]
BlindWriteKeyGenerator *MultiGenerator[Key]
ReadWriteValueGenerator *ByteArrayGenerator
BlindWriteValueGenerator *ByteArrayGenerator
Modifiers []Modifier
}
IndependentTxGenerator generates a new valid TX given key generators.
func (*IndependentTxGenerator) Next ¶
func (g *IndependentTxGenerator) Next() *servicepb.LoadGenTx
Next generate a new TX.
type KeyPath ¶
type KeyPath struct {
SigningKey string `mapstructure:"signing-key" yaml:"signing-key"`
VerificationKey string `mapstructure:"verification-key" yaml:"verification-key"`
SignCertificate string `mapstructure:"sign-certificate" yaml:"sign-certificate"`
}
KeyPath describes how to find/generate the signature keys.
type KeyProfile ¶
type KeyProfile struct {
// Size is the size of the key to generate.
Size uint32 `mapstructure:"size" yaml:"size"`
}
KeyProfile describes generated keys characteristics.
type MultiGenerator ¶
MultiGenerator generates an array of size determined by Count, with items generated by Gen.
func (*MultiGenerator[T]) Next ¶
func (g *MultiGenerator[T]) Next() []T
Next yields an array of items.
type NormalDist ¶
type NormalDist struct {
Mean float64 `mapstructure:"mean" yaml:"mean,omitempty"`
Std float64 `mapstructure:"std" yaml:"std,omitempty"`
}
NormalDist describes normal.
type NormalGenerator ¶
NormalGenerator generates values with a normal distribution.
func (*NormalGenerator) Next ¶
func (d *NormalGenerator) Next() float64
Next yields the next normal value.
type Policy ¶
type Policy struct {
Scheme signature.Scheme `mapstructure:"scheme" yaml:"scheme"`
Seed int64 `mapstructure:"seed" yaml:"seed"`
KeyPath *KeyPath `mapstructure:"key-path" yaml:"key-path"`
}
Policy describes how to sign/verify a TX. It supports a signing with a raw signing key, or via a local MSP. Scheme can be a valid signature schemes (NONE, ECDSA, BLS, or EDDSA) or MSP to indicate using a local MSP. When Scheme is not MSP, we generate a key using the given Seed, or loading one if KeyPath is given. When Scheme is MSP, we load the signing identities from the ArtifactsPath, ignoring Seed and KeyPath. In such case, we use the default rule, which state that all peer organization should sign.
type PolicyProfile ¶
type PolicyProfile struct {
// NamespacePolicies specifies the namespace policies.
NamespacePolicies map[string]*Policy `mapstructure:"namespace-policies" yaml:"namespace-policies"`
// OrdererEndpoints may specify the endpoints to add to the config block.
// If this field is empty, no endpoints will be configured.
// If ConfigBlockPath is specified, this value is ignored.
OrdererEndpoints []*commontypes.OrdererEndpoint `mapstructure:"orderer-endpoints" yaml:"orderer-endpoints"`
// ArtifactsPath may specify the path to the artifacts generated by CreateOrExtendConfigBlockWithCrypto().
// If this field is empty, the artifacts will be generated into a temporary folder.
// If this path does not exist, or it is empty, the artifacts will be generated into it.
// The config block will be fetched from ArtifactsPath.
ArtifactsPath string `mapstructure:"artifacts-path" yaml:"artifacts-path"`
// ChannelID and Identity are used to create the TX envelop.
ChannelID string `mapstructure:"channel-id"`
Identity *ordererconn.IdentityConfig `mapstructure:"identity"`
// PeerOrganizationCount may specify the number of peer organizations to generate if the ArtifactsPath
// is not provided.
PeerOrganizationCount uint32 `mapstructure:"peer-organization-count"`
}
PolicyProfile holds the policy information for the load generation.
func (*PolicyProfile) Validate ¶ added in v0.1.9
func (p *PolicyProfile) Validate() error
Validate checks that the PolicyProfile does not contain invalid entries. System namespaces (meta and config) must not be provided explicitly; their policies are derived from the config block.
type Probability ¶
type Probability = float64
Probability is a float in the closed interval [0,1].
const ( // Always is 100%. Always Probability = 1 // Never is 0%. Never Probability = 0 )
type Profile ¶
type Profile struct {
Block BlockProfile `mapstructure:"block" yaml:"block"`
Key KeyProfile `mapstructure:"key" yaml:"key"`
Transaction TransactionProfile `mapstructure:"transaction" yaml:"transaction"`
Query QueryProfile `mapstructure:"query" yaml:"query"`
Policy PolicyProfile `mapstructure:"policy" yaml:"policy"`
Conflicts ConflictProfile `mapstructure:"conflicts" yaml:"conflicts"`
// The seed to generate the seeds for each worker
Seed int64 `mapstructure:"seed" yaml:"seed"`
// Workers is the number of independent producers.
// Each worker uses a unique seed that is generated from the main seed.
// To ensure responsibility of items between runs (e.g., for query)
// the number of workers must be preserved.
Workers uint32 `mapstructure:"workers" yaml:"workers"`
}
Profile describes the generated workload characteristics. It only contains parameters that deterministically affect the generated items. The items order, however, might be affected by other parameters.
func DefaultProfile ¶
DefaultProfile is used for testing and benchmarking.
type QueryGenerator ¶
type QueryGenerator struct {
ValidKeyGenerator *ByteArrayGenerator
InvalidKeyGenerator *ByteArrayGenerator
Size Generator[int]
InvalidPortion Generator[float64]
ShuffleRnd *rand.Rand
Shuffle bool
}
QueryGenerator generates a new query for keys.
func (*QueryGenerator) Next ¶
func (g *QueryGenerator) Next() *committerpb.Query
Next generate a new query.
type QueryProfile ¶
type QueryProfile struct {
// The number of keys to query.
QuerySize *Distribution `mapstructure:"query-size" yaml:"query-size"`
// The minimal portion of invalid keys (1 => all keys are invalid).
// This is a lower bound since some valid keys might have failed to commit due to conflicts.
MinInvalidKeysPortion *Distribution `mapstructure:"min-invalid-keys-portion" yaml:"min-invalid-keys-portion"`
// If Shuffle=false, the valid keys will be placed first.
// Otherwise, they will be shuffled.
Shuffle bool `mapstructure:"shuffle" yaml:"shuffle"`
}
QueryProfile describes generate query characteristics.
type QueryStream ¶
type QueryStream struct {
// contains filtered or unexported fields
}
QueryStream generates stream's queries consumers.
func NewQueryGenerator ¶
func NewQueryGenerator(profile *Profile, options *StreamOptions) *QueryStream
NewQueryGenerator creates workers that generates queries into a queue.
func (*QueryStream) MakeGenerator ¶
func (s *QueryStream) MakeGenerator() *ConsumerRateController[*committerpb.Query]
MakeGenerator creates a new generator that consumes from the stream. Each generator must be used from a single goroutine, but different generators from the same Stream can be used concurrently.
type StreamOptions ¶
type StreamOptions struct {
// GenBatch impacts the rate by batching generated items before inserting then the channel.
// This helps overcome the inherit rate limitation of Go channels.
GenBatch uint32 `mapstructure:"gen-batch" yaml:"gen-batch"`
// BuffersSize impact the rate by masking fluctuation in performance.
BuffersSize int `mapstructure:"buffers-size" yaml:"buffers-size"`
// RateLimit directly impacts the rate by limiting it.
// TXs are released at RateLimit (default: unlimited).
RateLimit uint64 `mapstructure:"rate-limit" yaml:"rate-limit"`
}
StreamOptions allows adjustment to the stream rate. It only contains parameters that do not affect the produced items. However, these parameters might affect the order of the items.
func (*StreamOptions) Debug ¶
func (o *StreamOptions) Debug()
Debug outputs the stream configuration to stdout.
type StreamWithSetup ¶
type StreamWithSetup struct {
WorkloadSetupTXs channel.Reader[*servicepb.LoadGenTx]
TxStream *TxStream
}
StreamWithSetup implements the TxStream interface.
func (*StreamWithSetup) MakeTxGenerator ¶
func (c *StreamWithSetup) MakeTxGenerator() *TxGeneratorWithSetup
MakeTxGenerator instantiate clientTxGenerator.
type TransactionProfile ¶
type TransactionProfile struct {
// The sizes of the values to generate (size=0 => value=nil)
ReadWriteValueSize uint32 `mapstructure:"read-write-value-size" yaml:"read-write-value-size"`
BlindWriteValueSize uint32 `mapstructure:"blind-write-value-size" yaml:"blind-write-value-size"`
// The number of keys to generate (read ver=nil)
ReadOnlyCount *Distribution `mapstructure:"read-only-count" yaml:"read-only-count"`
// The number of keys to generate (read ver=nil/write)
ReadWriteCount *Distribution `mapstructure:"read-write-count" yaml:"read-write-count"`
// The number of keys to generate (write)
BlindWriteCount *Distribution `mapstructure:"write-count" yaml:"write-count"`
}
TransactionProfile describes generate TX characteristics.
type TxBuilder ¶ added in v0.1.6
type TxBuilder struct {
ChannelID string
EnvSigner identity.Signer
TxEndorser *TxEndorser
EnvCreator []byte
NonceSource io.Reader
}
TxBuilder is a convenient way to create an enveloped TX.
func NewTxBuilderFromPolicy ¶ added in v0.1.6
func NewTxBuilderFromPolicy(policy *PolicyProfile, nonceSource io.Reader) (*TxBuilder, error)
NewTxBuilderFromPolicy instantiate a TxBuilder from a given policy profile.
func (*TxBuilder) MakeTx ¶ added in v0.1.6
func (txb *TxBuilder) MakeTx(tx *applicationpb.Tx) *servicepb.LoadGenTx
MakeTx makes an enveloped TX with the builder's properties.
func (*TxBuilder) MakeTxWithID ¶ added in v0.1.6
MakeTxWithID makes an enveloped TX with the builder's properties. It uses the given TX-ID instead of generating a valid one.
type TxEndorser ¶ added in v0.1.8
type TxEndorser struct {
// contains filtered or unexported fields
}
TxEndorser supports endorsing a TX.
func NewTxEndorser ¶ added in v0.1.8
func NewTxEndorser(policy *PolicyProfile) *TxEndorser
NewTxEndorser creates a new TxEndorser given a workload profile.
func (*TxEndorser) Endorse ¶ added in v0.1.8
func (e *TxEndorser) Endorse(txID string, tx *applicationpb.Tx)
Endorse a TX.
func (*TxEndorser) VerificationPolicies ¶ added in v0.1.8
func (e *TxEndorser) VerificationPolicies() map[string]*applicationpb.NamespacePolicy
VerificationPolicies returns the verification policies.
type TxGeneratorWithSetup ¶
type TxGeneratorWithSetup struct {
WorkloadSetupTXs channel.Reader[*servicepb.LoadGenTx]
TxGen *ConsumerRateController[*servicepb.LoadGenTx]
}
TxGeneratorWithSetup is a TX generator that first submit TXs from the WorkloadSetupTXs, and blocks until indicated that it was committed. Then, it submits transactions from the tx stream.
func (*TxGeneratorWithSetup) Next ¶
func (g *TxGeneratorWithSetup) Next(ctx context.Context, p BlockProfile) []*servicepb.LoadGenTx
Next generates the next TX batch.
type TxStream ¶
type TxStream struct {
// contains filtered or unexported fields
}
TxStream yields transactions from the stream.
func NewTxStream ¶
func NewTxStream( profile *Profile, options *StreamOptions, modifierGenerators ...Generator[Modifier], ) *TxStream
NewTxStream creates workers that generates transactions into a queue and apply the modifiers. Each worker will have a unique instance of the modifier to avoid concurrency issues. The modifiers will be applied in the order they are given. A transaction modifier can modify any of its fields to adjust the workload. For example, a modifier can query the database for the read-set versions to simulate a real transaction. The signature modifier is applied last so all previous modifications will be signed correctly.
func (*TxStream) AppendBatch ¶
AppendBatch appends a batch to the stream.
func (*TxStream) MakeGenerator ¶
func (s *TxStream) MakeGenerator() *ConsumerRateController[*servicepb.LoadGenTx]
MakeGenerator creates a new generator that consumes from the stream. Each generator must be used from a single goroutine, but different generators from the same Stream can be used concurrently.
type UniformDist ¶
type UniformDist struct {
Min float64 `mapstructure:"min" yaml:"min,omitempty"`
Max float64 `mapstructure:"max" yaml:"max,omitempty"`
}
UniformDist describes uniform.
type UniformGenerator ¶
UniformGenerator generates values with a uniform distribution.
func (*UniformGenerator) Next ¶
func (d *UniformGenerator) Next() float64
Next yields the next uniform value.