This repository was archived by the owner on May 15, 2024. It is now read-only.
forked from hyperledger/fabric-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed cancellation of all outstanding requests in discovery service (…
…hyperledger#62) * Reworking of discovery client and services 1. Moved DisoveryClient interface to pkg/fab/discovery + mocks, all users can rely on this interface. 2. Reworked pkg/fab/discovery Send, now it returns a channel of Responses, cancellation of the context is delegated to users of this client. Error method was added to Response, so user can check if an error happened. 3. Fixed tests 4. Reworked chservice, localservice, fabricselection by using chan Response 5. Updated DiscoveryError by adding IsAccessDenied method, no need to expose const and compare msg every time. Signed-off-by: kopaygorodsky <[email protected]>
- Loading branch information
1 parent
594a8dc
commit f7729f1
Showing
17 changed files
with
500 additions
and
257 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
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,43 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package dynamicdiscovery | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
const ( | ||
// AccessDenied indicates that the user does not have permission to perform the operation | ||
AccessDenied = "access denied" | ||
) | ||
|
||
// DiscoveryError is an error originating at the Discovery service | ||
type DiscoveryError struct { | ||
error | ||
target string | ||
} | ||
|
||
//Error returns string representation with target | ||
func (e DiscoveryError) Error() string { | ||
return errors.Wrapf(e.error, "target [%s]", e.target).Error() | ||
} | ||
|
||
//Target returns url of the peer | ||
func (e DiscoveryError) Target() string { | ||
return e.target | ||
} | ||
|
||
//IsAccessDenied checks if response contains access denied msg | ||
func (e DiscoveryError) IsAccessDenied() bool { | ||
return strings.Contains(e.Error(), AccessDenied) | ||
} | ||
|
||
func newDiscoveryError(err error, target string) error { | ||
return DiscoveryError{target: target, error: err} | ||
} |
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
Oops, something went wrong.