match

package
v1.13.6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package match provides matching presets and utils for selecting devstack components.

Matchers can be composed, e.g.: - `And(OpGeth, WithLabel("name", "alice"))` to select the op-geth node named "alice". - `Or(OpGeth, OpReth)` to select an op-geth or op-reth node. - `Not(OpGeth)` to select anything but an op-geth node.

Custom matchers can also be implemented: - MatchFn can filter a list of elements down to just the matched elements - MatchElemFn can filter by checking each individual element

For convenience, aliases for common matchers are also provided, e.g. for matching "chain A", or matching the first L2 EL node.

Index

Constants

View Source
const (
	LabelVendor = "vendor"
)

Variables

View Source
var FirstCluster = First[stack.ClusterID, stack.Cluster]()
View Source
var FirstFaucet = First[stack.FaucetID, stack.Faucet]()
View Source
var FirstL1Network = First[stack.L1NetworkID, stack.L1Network]()
View Source
var FirstL2Batcher = First[stack.L2BatcherID, stack.L2Batcher]()
View Source
var FirstL2Challenger = First[stack.L2ChallengerID, stack.L2Challenger]()
View Source
var FirstL2Network = First[stack.L2NetworkID, stack.L2Network]()
View Source
var FirstL2Proposer = First[stack.L2ProposerID, stack.L2Proposer]()
View Source
var FirstSuperchain = First[stack.SuperchainID, stack.Superchain]()
View Source
var FirstSupervisor = First[stack.SupervisorID, stack.Supervisor]()
View Source
var FirstSyncTester = First[stack.SyncTesterID, stack.SyncTester]()
View Source
var FirstTestSequencer = First[stack.TestSequencerID, stack.TestSequencer]()

L2ChainA is an alias for the first L2 network.

L2ChainB is an alias for the second L2 network.

View Source
var SecondSupervisor = Second[stack.SupervisorID, stack.Supervisor]()

Functions

func And

func And[I comparable, E stack.Identifiable[I]](matchers ...stack.Matcher[I, E]) stack.Matcher[I, E]

And combines all the matchers, by running them all, narrowing down the set with each application. If none are provided, all inputs are matched.

func Assume

func Assume[I comparable, E stack.Identifiable[I]](t devtest.T, inner stack.Matcher[I, E]) stack.Matcher[I, E]

Assume skips the test if no elements were matched with the inner matcher

func ByIndex

func ByIndex[I comparable, E stack.Identifiable[I]](index int) stack.Matcher[I, E]

ByIndex matches element i (zero-indexed).

func EngineFor added in v1.13.5

func First

func First[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

func L2ChainById added in v1.13.4

L2ChainById returns a matcher for the L2 network with the given ID.

func Last

func Last[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

Last matches the last element.

func Not

func Not[I comparable, E stack.Identifiable[I]](matcher stack.Matcher[I, E]) stack.Matcher[I, E]

Not matches the elements that do not match the given matcher.

func Only

func Only[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

Only matches the only value. If there are none, or more than one, then no value is matched.

func Or

func Or[I comparable, E stack.Identifiable[I]](matchers ...stack.Matcher[I, E]) stack.Matcher[I, E]

Or returns each of the inputs that have a match with any of the matchers. All inputs are applied to all matchers, even if matched previously.

func Second

func Second[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

func WithLabel

func WithLabel[I comparable, E interface {
	stack.Identifiable[I]
	Label(key string) string
}](key, value string) stack.Matcher[I, E]

func WithSequencerActive added in v1.13.5

func WithSequencerActive(ctx context.Context) stack.Matcher[stack.L2CLNodeID, stack.L2CLNode]

Types

type MatchElemFn

type MatchElemFn[I comparable, E stack.Identifiable[I]] func(elem E) bool

MatchElemFn implements stack.Matcher, checking one element at a time.

func (MatchElemFn[I, E]) Match

func (m MatchElemFn[I, E]) Match(elems []E) (out []E)

func (MatchElemFn[I, E]) String

func (m MatchElemFn[I, E]) String() string

type MatchFn

type MatchFn[I comparable, E stack.Identifiable[I]] func(elems []E) []E

MatchFn implements stack.Matcher, checking all elements at once.

func (MatchFn[I, E]) Match

func (m MatchFn[I, E]) Match(elems []E) []E

func (MatchFn[I, E]) String

func (m MatchFn[I, E]) String() string

type Vendor added in v1.13.6

type Vendor string
const (
	OpReth                    Vendor = "op-reth"
	OpGeth                    Vendor = "op-geth"
	Proxyd                    Vendor = "proxyd"
	FlashblocksWebsocketProxy Vendor = "flashblocks-websocket-proxy"
	OpNode                    Vendor = "op-node"
	KonaNode                  Vendor = "kona-node"
)

func (Vendor) Match added in v1.13.6

func (v Vendor) Match(elems []stack.L2ELNode) []stack.L2ELNode

func (Vendor) String added in v1.13.6

func (v Vendor) String() string

Jump to

Keyboard shortcuts

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