github.com/yimialmonte/fabric@v2.1.1+incompatible/discovery/protoext/querytype.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package protoext
     8  
     9  import "github.com/hyperledger/fabric-protos-go/discovery"
    10  
    11  // QueryType defines the types of service discovery requests
    12  type QueryType uint8
    13  
    14  const (
    15  	InvalidQueryType QueryType = iota
    16  	ConfigQueryType
    17  	PeerMembershipQueryType
    18  	ChaincodeQueryType
    19  	LocalMembershipQueryType
    20  )
    21  
    22  // GetType returns the type of the request
    23  func GetQueryType(q *discovery.Query) QueryType {
    24  	switch {
    25  	case q.GetCcQuery() != nil:
    26  		return ChaincodeQueryType
    27  	case q.GetConfigQuery() != nil:
    28  		return ConfigQueryType
    29  	case q.GetPeerQuery() != nil:
    30  		return PeerMembershipQueryType
    31  	case q.GetLocalPeers() != nil:
    32  		return LocalMembershipQueryType
    33  	default:
    34  		return InvalidQueryType
    35  	}
    36  }