-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-8839] Use connection cache in event client
The deliver and event hub client now use the connection cache. Change-Id: Iab7906eb006de4a27e97ab5de386077aa71ab99e Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
- Loading branch information
1 parent
cc87976
commit 8f5d6f4
Showing
6 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package comm | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab" | ||
fabmocks "github.com/hyperledger/fabric-sdk-go/pkg/fab/mocks" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// MockCommManager is a non-caching comm manager used | ||
// for unit testing | ||
type MockCommManager struct { | ||
} | ||
|
||
// DialContext creates a connection | ||
func (m *MockCommManager) DialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { | ||
return grpc.DialContext(ctx, target, opts...) | ||
} | ||
|
||
// ReleaseConn closes the connection | ||
func (m *MockCommManager) ReleaseConn(conn *grpc.ClientConn) { | ||
if err := conn.Close(); err != nil { | ||
logger.Warnf("Error closing connection: %s", err) | ||
} | ||
} | ||
|
||
// MockInfraProvider overrides the comm manager to return | ||
// the MockCommManager | ||
type MockInfraProvider struct { | ||
fabmocks.MockInfraProvider | ||
} | ||
|
||
// NewMockInfraProvider return a new MockInfraProvider | ||
func NewMockInfraProvider() *MockInfraProvider { | ||
return &MockInfraProvider{} | ||
} | ||
|
||
// CommManager returns the MockCommManager | ||
func (f *MockInfraProvider) CommManager() fab.CommManager { | ||
return &MockCommManager{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters