Bound concurrent section work and finalize proposal identities in order
This commit is contained in:
@@ -22,3 +22,24 @@ type InteractionArtifacts struct {
|
||||
ResponsePayloadPath string `json:"response_payload_path,omitempty"`
|
||||
ErrorPayloadPath string `json:"error_payload_path,omitempty"`
|
||||
}
|
||||
|
||||
// IndexedInteraction builds an artifact after the section's ordered proposal
|
||||
// indices and paths from earlier interactions are available.
|
||||
type IndexedInteraction func(offset int, resolvePath func(string) string) Interaction
|
||||
|
||||
func WriteIndexedInteraction(sink InteractionSink, build IndexedInteraction) (InteractionArtifacts, error) {
|
||||
if deferred, ok := sink.(interface {
|
||||
WriteIndexedInteraction(IndexedInteraction) (InteractionArtifacts, error)
|
||||
}); ok {
|
||||
return deferred.WriteIndexedInteraction(build)
|
||||
}
|
||||
return sink.WriteInteraction(build(0, func(path string) string { return path }))
|
||||
}
|
||||
|
||||
func OffsetProposalIndex(index *int, offset int) *int {
|
||||
if index == nil || offset == 0 {
|
||||
return index
|
||||
}
|
||||
next := *index + offset
|
||||
return &next
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user