MCPcopy
hub / github.com/grafana/k6 / NewExecutionSegmentSequence

Function NewExecutionSegmentSequence

lib/execution_segment.go:305–319  ·  view source on GitHub ↗

NewExecutionSegmentSequence validates the that the supplied execution segments are non-overlapping and without gaps. It will return a new execution segment sequence if that is true, and an error if it's not.

(segments ...*ExecutionSegment)

Source from the content-addressed store, hash-verified

303// segments are non-overlapping and without gaps. It will return a new execution
304// segment sequence if that is true, and an error if it's not.
305func NewExecutionSegmentSequence(segments ...*ExecutionSegment) (ExecutionSegmentSequence, error) {
306 if len(segments) > 1 {
307 to := segments[0].to
308 for i, segment := range segments[1:] {
309 if segment.from.Cmp(to) != 0 {
310 return nil, fmt.Errorf(
311 "the start value %s of segment #%d must be equal to the end value of the previous one, but it is %s",
312 segment.from, i+1, to,
313 )
314 }
315 to = segment.to
316 }
317 }
318 return ExecutionSegmentSequence(segments), nil
319}
320
321// NewExecutionSegmentSequenceFromString parses strings of the format
322// "r1,r2,r3,...,rn", which represents the sequences like (r1, r2], (r2, r3],

Calls 2

ExecutionSegmentSequenceTypeAlias · 0.85
ErrorfMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…