Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
use context for terminate of operation and s/gogo/golang/gi (#31)
Browse files Browse the repository at this point in the history
* use context for terminate of operation and `s/gogo/golang/gi`

* pretty go.mod for up golang-ci
  • Loading branch information
inotnako authored and vitiko committed Nov 28, 2019
1 parent c369ffc commit 539548a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
8 changes: 6 additions & 2 deletions gateway/event_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ func (s *ChaincodeEventServerStream) SendMsg(m interface{}) (err error) {
}
}

s.events <- e
select {
case <-s.context.Done():
return s.context.Err()
case s.events <- e:
}

return nil
}

Expand All @@ -82,7 +87,6 @@ func (s *ChaincodeEventServerStream) Events() <-chan *peer.ChaincodeEvent {

func (s *ChaincodeEventServerStream) Close() {
s.once.Do(func() {
close(s.events)
s.ready = false
})
}
17 changes: 11 additions & 6 deletions gateway/service/mock/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ func (cs *ChaincodeService) Events(in *service.ChaincodeLocator, stream service.
return
}
events := mockStub.EventSubscription()
ctx := stream.Context()
for {
e, ok := <-events
if !ok {
return nil
}
if err = stream.Send(e); err != nil {
return err
select {
case <-ctx.Done():
return ctx.Err()
case e, ok := <-events:
if !ok {
return nil
}
if err = stream.Send(e); err != nil {
return err
}
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
module github.com/s7techlab/cckit

go 1.12
go 1.13

require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/fsouza/go-dockerclient v1.4.0 // indirect
github.com/gogo/protobuf v1.2.1
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/mock v1.2.0 // indirect
github.com/golang/protobuf v1.3.1
github.com/grpc-ecosystem/grpc-gateway v1.9.0
github.com/hyperledger/fabric v1.4.0
github.com/hyperledger/fabric-amcl v0.0.0-20181230093703-5ccba6eab8d6 // indirect
github.com/miekg/pkcs11 v1.0.2 // indirect
github.com/mwitkow/go-proto-validators v0.0.0-20190212092829-1f388280e944
github.com/onsi/ginkgo v1.8.0
Expand All @@ -20,9 +16,6 @@ require (
github.com/pkg/errors v0.8.1
github.com/s7techlab/hlf-sdk-go v0.1.3
github.com/spf13/viper v1.4.0 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19
google.golang.org/grpc v1.21.0
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.12.0
2 changes: 1 addition & 1 deletion identity/cert_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/pem"
"time"

"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/lib/cid"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/msp"
Expand Down
2 changes: 1 addition & 1 deletion router/param/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package param
import (
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"github.com/s7techlab/cckit/convert"
"github.com/s7techlab/cckit/router"
Expand Down
2 changes: 1 addition & 1 deletion state/state_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/golang/protobuf/ptypes"

"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/pkg/errors"
"github.com/s7techlab/cckit/state/schema"
Expand Down

0 comments on commit 539548a

Please sign in to comment.