@@ -29,7 +29,7 @@ func newEdge(ed Edge, op activeOp, index *edgeIndex) *edge {
29
29
e := & edge {
30
30
edge : ed ,
31
31
op : op ,
32
- depRequests : map [pipe. Receiver ]* dep {},
32
+ depRequests : map [pipeReceiver ]* dep {},
33
33
keyMap : map [string ]struct {}{},
34
34
cacheRecords : map [string ]* CacheRecord {},
35
35
cacheRecordsLoaded : map [string ]struct {}{},
@@ -65,14 +65,14 @@ type edge struct {
65
65
op activeOp
66
66
67
67
edgeState
68
- depRequests map [pipe. Receiver ]* dep
68
+ depRequests map [pipeReceiver ]* dep
69
69
deps []* dep
70
70
71
- cacheMapReq pipe. Receiver
71
+ cacheMapReq pipeReceiver
72
72
cacheMapDone bool
73
73
cacheMapIndex int
74
74
cacheMapDigests []digest.Digest
75
- execReq pipe. Receiver
75
+ execReq pipeReceiver
76
76
execCacheLoad bool
77
77
err error
78
78
cacheRecords map [string ]* CacheRecord
@@ -99,11 +99,11 @@ type edge struct {
99
99
100
100
// dep holds state for a dependant edge
101
101
type dep struct {
102
- req pipe. Receiver
102
+ req pipeReceiver
103
103
edgeState
104
104
index Index
105
105
keyMap map [string ]* CacheKey
106
- slowCacheReq pipe. Receiver
106
+ slowCacheReq pipeReceiver
107
107
slowCacheComplete bool
108
108
slowCacheFoundKey bool
109
109
slowCacheKey * ExportableCacheKey
@@ -122,7 +122,7 @@ func newDep(i Index) *dep {
122
122
123
123
// edgePipe is a pipe for requests between two edges
124
124
type edgePipe struct {
125
- * pipe.Pipe
125
+ * pipe.Pipe [ * edgeRequest , any ]
126
126
From , Target * edge
127
127
mu sync.Mutex
128
128
}
@@ -198,21 +198,21 @@ func (e *edge) isComplete() bool {
198
198
}
199
199
200
200
// finishIncoming finalizes the incoming pipe request
201
- func (e * edge ) finishIncoming (req pipe. Sender ) {
201
+ func (e * edge ) finishIncoming (req pipeSender ) {
202
202
err := e .err
203
203
if req .Request ().Canceled && err == nil {
204
204
err = context .Canceled
205
205
}
206
206
if e .debug {
207
- bklog .G (context .TODO ()).Debugf ("finishIncoming %s %v %#v desired=%s" , e .edge .Vertex .Name (), err , e .edgeState , req .Request ().Payload .( * edgeRequest ). desiredState )
207
+ bklog .G (context .TODO ()).Debugf ("finishIncoming %s %v %#v desired=%s" , e .edge .Vertex .Name (), err , e .edgeState , req .Request ().Payload .desiredState )
208
208
}
209
209
req .Finalize (& e .edgeState , err )
210
210
}
211
211
212
212
// updateIncoming updates the current value of incoming pipe request
213
- func (e * edge ) updateIncoming (req pipe. Sender ) {
213
+ func (e * edge ) updateIncoming (req pipeSender ) {
214
214
if e .debug {
215
- bklog .G (context .TODO ()).Debugf ("updateIncoming %s %#v desired=%s" , e .edge .Vertex .Name (), e .edgeState , req .Request ().Payload .( * edgeRequest ). desiredState )
215
+ bklog .G (context .TODO ()).Debugf ("updateIncoming %s %#v desired=%s" , e .edge .Vertex .Name (), e .edgeState , req .Request ().Payload .desiredState )
216
216
}
217
217
req .Update (& e .edgeState )
218
218
}
@@ -353,7 +353,7 @@ func (e *edge) skipPhase2FastCache(dep *dep) bool {
353
353
// requests were not completed
354
354
// 2. this function may not return outgoing requests if it has completed all
355
355
// incoming requests
356
- func (e * edge ) unpark (incoming []pipe. Sender , updates , allPipes []pipe. Receiver , f * pipeFactory ) {
356
+ func (e * edge ) unpark (incoming []pipeSender , updates , allPipes []pipeReceiver , f * pipeFactory ) {
357
357
// process all incoming changes
358
358
depChanged := false
359
359
for _ , upt := range updates {
@@ -414,7 +414,7 @@ func (e *edge) markFailed(f *pipeFactory, err error) {
414
414
}
415
415
416
416
// processUpdate is called by unpark for every updated pipe request
417
- func (e * edge ) processUpdate (upt pipe. Receiver ) (depChanged bool ) {
417
+ func (e * edge ) processUpdate (upt pipeReceiver ) (depChanged bool ) {
418
418
// response for cachemap request
419
419
if upt == e .cacheMapReq && upt .Status ().Completed {
420
420
if err := upt .Status ().Err ; err != nil {
@@ -719,7 +719,7 @@ func (e *edge) recalcCurrentState() {
719
719
720
720
// respondToIncoming responds to all incoming requests. completing or
721
721
// updating them when possible
722
- func (e * edge ) respondToIncoming (incoming []pipe. Sender , allPipes []pipe. Receiver ) (edgeStatusType , bool ) {
722
+ func (e * edge ) respondToIncoming (incoming []pipeSender , allPipes []pipeReceiver ) (edgeStatusType , bool ) {
723
723
// detect the result state for the requests
724
724
allIncomingCanComplete := true
725
725
desiredState := e .state
@@ -731,7 +731,7 @@ func (e *edge) respondToIncoming(incoming []pipe.Sender, allPipes []pipe.Receive
731
731
for _ , req := range incoming {
732
732
if ! req .Request ().Canceled {
733
733
allCanceled = false
734
- if r := req .Request ().Payload .( * edgeRequest ) ; desiredState < r .desiredState {
734
+ if r := req .Request ().Payload ; desiredState < r .desiredState {
735
735
desiredState = r .desiredState
736
736
if e .hasActiveOutgoing || r .desiredState == edgeStatusComplete || r .currentKeys == len (e .keys ) {
737
737
allIncomingCanComplete = false
@@ -757,7 +757,7 @@ func (e *edge) respondToIncoming(incoming []pipe.Sender, allPipes []pipe.Receive
757
757
}
758
758
759
759
// can close all but one requests
760
- var leaveOpen pipe. Sender
760
+ var leaveOpen pipeSender
761
761
for _ , req := range incoming {
762
762
if ! req .Request ().Canceled {
763
763
leaveOpen = req
@@ -784,7 +784,7 @@ func (e *edge) respondToIncoming(incoming []pipe.Sender, allPipes []pipe.Receive
784
784
785
785
// update incoming based on current state
786
786
for _ , req := range incoming {
787
- r := req .Request ().Payload .( * edgeRequest )
787
+ r := req .Request ().Payload
788
788
if req .Request ().Canceled {
789
789
e .finishIncoming (req )
790
790
} else if ! e .hasActiveOutgoing && e .state >= r .desiredState {
@@ -803,7 +803,7 @@ func (e *edge) createInputRequests(desiredState edgeStatusType, f *pipeFactory,
803
803
804
804
// initialize deps state
805
805
if e .deps == nil {
806
- e .depRequests = make (map [pipe. Receiver ]* dep )
806
+ e .depRequests = make (map [pipeReceiver ]* dep )
807
807
e .deps = make ([]* dep , 0 , len (e .edge .Vertex .Inputs ()))
808
808
for i := range e .edge .Vertex .Inputs () {
809
809
e .deps = append (e .deps , newDep (Index (i )))
@@ -842,13 +842,13 @@ func (e *edge) createInputRequests(desiredState edgeStatusType, f *pipeFactory,
842
842
if dep .state < desiredStateDep {
843
843
addNew := true
844
844
if dep .req != nil && ! dep .req .Status ().Completed {
845
- if dep .req .Request ().( * edgeRequest ). desiredState != desiredStateDep {
845
+ if dep .req .Request ().desiredState != desiredStateDep {
846
846
if e .debug {
847
847
bklog .G (context .TODO ()).
848
848
WithField ("edge_vertex_name" , e .edge .Vertex .Name ()).
849
849
WithField ("edge_vertex_digest" , e .edge .Vertex .Digest ()).
850
850
WithField ("dep_index" , dep .index ).
851
- WithField ("dep_req_desired_state" , dep .req .Request ().( * edgeRequest ). desiredState ).
851
+ WithField ("dep_req_desired_state" , dep .req .Request ().desiredState ).
852
852
WithField ("dep_desired_state" , desiredStateDep ).
853
853
WithField ("dep_state" , dep .state ).
854
854
Debug ("cancel input request" )
@@ -860,7 +860,7 @@ func (e *edge) createInputRequests(desiredState edgeStatusType, f *pipeFactory,
860
860
WithField ("edge_vertex_name" , e .edge .Vertex .Name ()).
861
861
WithField ("edge_vertex_digest" , e .edge .Vertex .Digest ()).
862
862
WithField ("dep_index" , dep .index ).
863
- WithField ("dep_req_desired_state" , dep .req .Request ().( * edgeRequest ). desiredState ).
863
+ WithField ("dep_req_desired_state" , dep .req .Request ().desiredState ).
864
864
WithField ("dep_desired_state" , desiredStateDep ).
865
865
WithField ("dep_state" , dep .state ).
866
866
Debug ("skip input request based on existing request" )
@@ -1062,3 +1062,13 @@ func withSelector(keys []ExportableCacheKey, selector digest.Digest) []CacheKeyW
1062
1062
}
1063
1063
return out
1064
1064
}
1065
+
1066
+ type (
1067
+ pipeRequest = pipe.Request [* edgeRequest ]
1068
+ pipeSender = pipe.Sender [* edgeRequest , any ]
1069
+ pipeReceiver = pipe.Receiver [* edgeRequest , any ]
1070
+ )
1071
+
1072
+ func newPipe (req pipeRequest ) * pipe.Pipe [* edgeRequest , any ] {
1073
+ return pipe.New [* edgeRequest , any ](req )
1074
+ }
0 commit comments