1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00

sync/pipeline: select context for timeout/cancel (#478)

This commit is contained in:
Astone 2020-01-17 13:12:33 +08:00 committed by Tony
parent 8691205479
commit 094ee714bd

View File

@ -122,9 +122,14 @@ func (p *Pipeline) Start() {
}
// SyncAdd sync add a value to channal, channel shard in split method
func (p *Pipeline) SyncAdd(c context.Context, key string, value interface{}) {
func (p *Pipeline) SyncAdd(c context.Context, key string, value interface{}) (err error) {
ch, msg := p.add(c, key, value)
ch <- msg
select {
case ch <- msg:
case <-c.Done():
err = c.Err()
}
return
}
// Add async add a value to channal, channel shard in split method