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:
parent
8691205479
commit
094ee714bd
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user