parallel

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryZgsRpc added in v0.6.0

func QueryZgsRpc[T any](ctx context.Context, nodes []string, rpcFunc func(*node.ZgsClient, context.Context) (T, error), option ...RpcOption) map[string]*RpcResult[T]

QueryZgsRpc calls zgs RPC with given nodes in parallel.

func Serial

func Serial(ctx context.Context, parallelizable Interface, tasks int, option ...SerialOption) error

Types

type Interface

type Interface interface {
	ParallelDo(ctx context.Context, routine, task int) (interface{}, error)
	ParallelCollect(result *Result) error
}

type Result

type Result struct {
	Routine int
	Task    int
	Value   interface{}
	// contains filtered or unexported fields
}

type RpcOption added in v0.6.0

type RpcOption struct {
	Parallel       SerialOption
	Provider       providers.Option
	ReportInterval time.Duration
}

type RpcResult added in v0.6.0

type RpcResult[T any] struct {
	Data    T
	Err     error
	Latency time.Duration
}

type SerialOption added in v0.6.0

type SerialOption struct {
	Routines int
	Window   int
}

func (*SerialOption) Normalize added in v0.6.0

func (opt *SerialOption) Normalize(tasks int)

Jump to

Keyboard shortcuts

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