Skip to content
Snippets Groups Projects
Select Git revision
  • 7eaa2f691017e799329807be2ede9619193d9041
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

plugin.go

Blame
  • options.go 1.07 KiB
    package batchworkerpool
    
    import (
    	"runtime"
    	"time"
    )
    
    var DEFAULT_OPTIONS = &Options{
    	WorkerCount:            2 * runtime.NumCPU(),
    	QueueSize:              2 * runtime.NumCPU() * 64,
    	BatchSize:              64,
    	BatchCollectionTimeout: 15 * time.Millisecond,
    }
    
    func WorkerCount(workerCount int) Option {
    	return func(args *Options) {
    		args.WorkerCount = workerCount
    	}
    }
    
    func BatchSize(batchSize int) Option {
    	return func(args *Options) {
    		args.BatchSize = batchSize
    	}
    }
    
    func BatchCollectionTimeout(batchCollectionTimeout time.Duration) Option {
    	return func(args *Options) {
    		args.BatchCollectionTimeout = batchCollectionTimeout
    	}
    }
    
    func QueueSize(queueSize int) Option {
    	return func(args *Options) {
    		args.QueueSize = queueSize
    	}
    }
    
    type Options struct {
    	WorkerCount            int
    	QueueSize              int
    	BatchSize              int
    	BatchCollectionTimeout time.Duration
    }
    
    func (options Options) Override(optionalOptions ...Option) *Options {
    	result := &options
    	for _, option := range optionalOptions {
    		option(result)
    	}
    
    	return result
    }
    
    type Option func(*Options)