Skip to content

Commit

Permalink
fix ch4-04-3
Browse files Browse the repository at this point in the history
  • Loading branch information
alphayan committed Aug 18, 2018
1 parent 72f72eb commit 2305589
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ch4-rpc/ch4-04-grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,26 @@ for {
```go
import (
"github.com/docker/docker/pkg/pubsub"
"time"
"fmt"
"strings"
"runtime"
)

func main() {
p := pubsub.NewPublisher(100*time.Millisecond, 10)

golang := p.SubscribeTopic(func(v interface{}) bool {
if key, ok := v.(string); ok {
if strings.Hasprefix("golang:") {
if strings.HasPrefix(key,"golang:") {
return true
}
}
return false
})
docker := p.SubscribeTopic(func(v interface{}) bool {
if key, ok := v.(string); ok {
if strings.Hasprefix("docker:") {
if strings.HasPrefix(key,"docker:") {
return true
}
}
Expand All @@ -250,8 +254,10 @@ func main() {
go func () {
fmt.Println("docker topic:", <-docker)
} ()
for {
runtime.Gosched()
}

<-make(chan bool)
}
```

Expand Down

0 comments on commit 2305589

Please sign in to comment.