fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/pkg/fab/discovery Index | Files | Directories

package discovery

import "github.com/hyperledger/fabric-sdk-go/pkg/fab/discovery"

Index

Package Files

discovery.go mockdiscoveryclient.go request.go

func CcCalls Uses

func CcCalls(ccNames ...string) []*discovery.ChaincodeCall

CcCalls creates an array of ChaincodeCalls based of cc names, can be used in AddPeersQuery(CcCalls(...))

func CcInterests Uses

func CcInterests(invocationsChains ...[]*discovery.ChaincodeCall) []*discovery.ChaincodeInterest

CcInterests creates an array of ChaincodeInterests based of ChaincodeCalls, can be used in AddEndorsersQuery(CcInterests(CcCalls(...)))

type Client Uses

type Client interface {
    Send(ctx context.Context, req *Request, targets ...fab.PeerConfig) (<-chan Response, error)
}

Client gives ability to send discovery request to multiple targets. There are cases when multiple targets requested and some of them are hanging, recommended to cancel ctx after first successful response. Note: "access denied" is a success response, so check for it after response evaluation.

func New Uses

func New(ctx fabcontext.Client) (Client, error)

New returns a new Discover client

type MockDiscoverEndpointResponse Uses

type MockDiscoverEndpointResponse struct {
    Target        string
    PeerEndpoints []*mocks.MockDiscoveryPeerEndpoint
    Error         error
    //todo it's really hard to make an expectation in tests, maybe we need to switch to mocks because current thing is stub
    AccessDenied bool
}

MockDiscoverEndpointResponse contains a mock response for the discover client

func (*MockDiscoverEndpointResponse) Build Uses

func (b *MockDiscoverEndpointResponse) Build() Response

Build builds a mock discovery response

type MockDiscoveryClient Uses

type MockDiscoveryClient struct {
    // contains filtered or unexported fields
}

MockDiscoveryClient implements a mock Discover service

func NewMockDiscoveryClient Uses

func NewMockDiscoveryClient() *MockDiscoveryClient

NewMockDiscoveryClient returns a new mock Discover service

func (*MockDiscoveryClient) Send Uses

func (m *MockDiscoveryClient) Send(ctx context.Context, req *Request, targets ...fab.PeerConfig) (<-chan Response, error)

Send sends a Discovery request

func (*MockDiscoveryClient) SetResponses Uses

func (m *MockDiscoveryClient) SetResponses(responses ...MockResponseBuilder)

SetResponses sets the responses that the mock client should return from the Send function

type MockResponseBuilder Uses

type MockResponseBuilder interface {
    Build() Response
}

MockResponseBuilder builds a mock discovery response

type Request Uses

type Request struct {
    // contains filtered or unexported fields
}

Request aggregates several queries inside it

func NewRequest Uses

func NewRequest() *Request

NewRequest creates a new request

func (*Request) AddConfigQuery Uses

func (req *Request) AddConfigQuery() *Request

AddConfigQuery adds to the request a config query

func (*Request) AddEndorsersQuery Uses

func (req *Request) AddEndorsersQuery(interests ...*discovery.ChaincodeInterest) (*Request, error)

AddEndorsersQuery adds to the request a query for given chaincodes interests are the chaincode interests that the client wants to query for. All interests for a given channel should be supplied in an aggregated slice

func (*Request) AddLocalPeersQuery Uses

func (req *Request) AddLocalPeersQuery() *Request

AddLocalPeersQuery adds to the request a local peer query

func (*Request) AddPeersQuery Uses

func (req *Request) AddPeersQuery(invocationChain ...*discovery.ChaincodeCall) *Request

AddPeersQuery adds to the request a peer query

func (*Request) OfChannel Uses

func (req *Request) OfChannel(ch string) *Request

OfChannel sets the next queries added to be in the given channel's context

type Response Uses

type Response interface {
    discclient.Response
    Target() string
    Error() error
}

Response extends the response from the Discovery invocation on the peer by adding the endpoint URL of the peer that was invoked.

Directories

PathSynopsis
mocks

Package discovery imports 15 packages (graph) and is imported by 2 packages. Updated 2020-04-29. Refresh now. Tools for package owners.