Documentation
¶
Overview ¶
Package resmgmt enables creation and update of resources on a Fabric network. It allows administrators to create and/or update channnels, and for peers to join channels. Administrators can also perform chaincode related operations on a peer, such as installing, instantiating, and upgrading chaincode.
Basic Flow: 1) Prepare client context 2) Create resource managememt client 3) Create new channel 4) Peer(s) join channel 5) Install chaincode onto peer(s) filesystem 6) Instantiate chaincode on channel 7) Query peer for channels, installed/instantiated chaincodes etc.
Example ¶
Output: Network setup completed
Index ¶
- Constants
- type Client
- func (rc *Client) InstallCC(req InstallCCRequest, options ...RequestOption) ([]InstallCCResponse, error)
- func (rc *Client) InstantiateCC(channelID string, req InstantiateCCRequest, options ...RequestOption) (InstantiateCCResponse, error)
- func (rc *Client) JoinChannel(channelID string, options ...RequestOption) error
- func (rc *Client) QueryChannels(options ...RequestOption) (*pb.ChannelQueryResponse, error)
- func (rc *Client) QueryConfigFromOrderer(channelID string, options ...RequestOption) (fab.ChannelCfg, error)
- func (rc *Client) QueryInstalledChaincodes(options ...RequestOption) (*pb.ChaincodeQueryResponse, error)
- func (rc *Client) QueryInstantiatedChaincodes(channelID string, options ...RequestOption) (*pb.ChaincodeQueryResponse, error)
- func (rc *Client) SaveChannel(req SaveChannelRequest, options ...RequestOption) (SaveChannelResponse, error)
- func (rc *Client) UpgradeCC(channelID string, req UpgradeCCRequest, options ...RequestOption) (UpgradeCCResponse, error)
- type ClientOption
- type InstallCCRequest
- type InstallCCResponse
- type InstantiateCCRequest
- type InstantiateCCResponse
- type RequestOption
- func WithOrderer(orderer fab.Orderer) RequestOption
- func WithOrdererEndpoint(key string) RequestOption
- func WithParentContext(parentContext reqContext.Context) RequestOption
- func WithRetry(retryOpt retry.Opts) RequestOption
- func WithTargetEndpoints(keys ...string) RequestOption
- func WithTargetFilter(targetFilter fab.TargetFilter) RequestOption
- func WithTargets(targets ...fab.Peer) RequestOption
- func WithTimeout(timeoutType fab.TimeoutType, timeout time.Duration) RequestOption
- type SaveChannelRequest
- type SaveChannelResponse
- type UpgradeCCRequest
- type UpgradeCCResponse
Examples ¶
- Package
- Client.InstallCC
- Client.InstantiateCC
- Client.JoinChannel
- Client.QueryChannels
- Client.QueryInstalledChaincodes
- Client.QueryInstantiatedChaincodes
- Client.SaveChannel
- Client.SaveChannel (WithOrdererEndpoint)
- Client.UpgradeCC
- New
- WithDefaultTargetFilter
- WithParentContext
- WithTargetFilter
- WithTargets
Constants ¶
const ( InstantiateChaincode chaincodeProposalType = iota UpgradeChaincode )
Define chaincode proposal types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client enables managing resources in Fabric network.
func New ¶
func New(ctxProvider context.ClientProvider, opts ...ClientOption) (*Client, error)
New returns a resource management client instance.
Example ¶
Output: resource management client created
func (*Client) InstallCC ¶
func (rc *Client) InstallCC(req InstallCCRequest, options ...RequestOption) ([]InstallCCResponse, error)
InstallCC allows administrators to install chaincode onto the filesystem of a peer. If peer(s) are not specified in options it will default to all peers that belong to admin's MSP.
Parameters: req holds info about mandatory chaincode name, path, version and policy options holds optional request options Returns: install chaincode proposal responses from peer(s)
Example ¶
Output: Chaincode installed
func (*Client) InstantiateCC ¶
func (rc *Client) InstantiateCC(channelID string, req InstantiateCCRequest, options ...RequestOption) (InstantiateCCResponse, error)
InstantiateCC instantiates chaincode with optional custom options (specific peers, filtered peers, timeout). If peer(s) are not specified in options it will default to all channel peers.
Parameters: channel is manadatory channel name req holds info about mandatory chaincode name, path, version and policy options holds optional request options Returns: instantiate chaincode response with transaction ID
Example ¶
Output: Chaincode instantiated
func (*Client) JoinChannel ¶
func (rc *Client) JoinChannel(channelID string, options ...RequestOption) error
JoinChannel allows for peers to join existing channel with optional custom options (specific peers, filtered peers). If peer(s) are not specified in options it will default to all peers that belong to client's MSP.
Parameters: channel is manadatory channel name options holds optional request options Returns: an error if join fails
Example ¶
Output: Joined channel
func (*Client) QueryChannels ¶
func (rc *Client) QueryChannels(options ...RequestOption) (*pb.ChannelQueryResponse, error)
QueryChannels queries the names of all the channels that a peer has joined.
Parameters: options hold optional request options Note: One target(peer) has to be specified using either WithTargetURLs or WithTargets request option Returns: all channels that peer has joined
Example ¶
Output: Retrieved channels
func (*Client) QueryConfigFromOrderer ¶
func (rc *Client) QueryConfigFromOrderer(channelID string, options ...RequestOption) (fab.ChannelCfg, error)
QueryConfigFromOrderer config returns channel configuration from orderer. If orderer is not provided using options it will be defaulted to channel orderer (if configured) or random orderer from configuration.
Parameters: channelID is mandatory channel ID options holds optional request options Returns: channel configuration
func (*Client) QueryInstalledChaincodes ¶
func (rc *Client) QueryInstalledChaincodes(options ...RequestOption) (*pb.ChaincodeQueryResponse, error)
QueryInstalledChaincodes queries the installed chaincodes on a peer.
Parameters: options hold optional request options Note: One target(peer) has to be specified using either WithTargetURLs or WithTargets request option Returns: list of installed chaincodes on specified peer
Example ¶
Output: Retrieved installed chaincodes
func (*Client) QueryInstantiatedChaincodes ¶
func (rc *Client) QueryInstantiatedChaincodes(channelID string, options ...RequestOption) (*pb.ChaincodeQueryResponse, error)
QueryInstantiatedChaincodes queries the instantiated chaincodes on a peer for specific channel. If peer is not specified in options it will query random peer on this channel.
Parameters: channel is manadatory channel name options hold optional request options Returns: list of instantiated chaincodes
Example ¶
Output: Retrieved instantiated chaincodes
func (*Client) SaveChannel ¶
func (rc *Client) SaveChannel(req SaveChannelRequest, options ...RequestOption) (SaveChannelResponse, error)
SaveChannel creates or updates channel.
Parameters: req holds info about mandatory channel name and configuration options holds optional request options Returns: save channel response with transaction ID
Example ¶
Output: Saved channel
Example (WithOrdererEndpoint) ¶
Output: Saved channel
func (*Client) UpgradeCC ¶
func (rc *Client) UpgradeCC(channelID string, req UpgradeCCRequest, options ...RequestOption) (UpgradeCCResponse, error)
UpgradeCC upgrades chaincode with optional custom options (specific peers, filtered peers, timeout). If peer(s) are not specified in options it will default to all channel peers.
Parameters: channel is manadatory channel name req holds info about mandatory chaincode name, path, version and policy options holds optional request options Returns: upgrade chaincode response with transaction ID
Example ¶
Output: Chaincode upgraded
type ClientOption ¶
ClientOption describes a functional parameter for the New constructor
func WithDefaultTargetFilter ¶
func WithDefaultTargetFilter(filter fab.TargetFilter) ClientOption
WithDefaultTargetFilter option to configure default target filter per client
Example ¶
Output: resource management client created with url target filter
type InstallCCRequest ¶
InstallCCRequest contains install chaincode request parameters
type InstallCCResponse ¶
InstallCCResponse contains install chaincode response status
type InstantiateCCRequest ¶
type InstantiateCCRequest struct { Name string Path string Version string Args [][]byte Policy *common.SignaturePolicyEnvelope CollConfig []*common.CollectionConfig }
InstantiateCCRequest contains instantiate chaincode request parameters
type InstantiateCCResponse ¶
type InstantiateCCResponse struct {
TransactionID fab.TransactionID
}
InstantiateCCResponse contains response parameters for instantiate chaincode
type RequestOption ¶
RequestOption func for each Opts argument
func WithOrderer ¶
func WithOrderer(orderer fab.Orderer) RequestOption
WithOrderer allows an orderer to be specified for the request.
func WithOrdererEndpoint ¶
func WithOrdererEndpoint(key string) RequestOption
WithOrdererEndpoint allows an orderer to be specified for the request. The orderer will be looked-up based on the key argument. key argument can be a name or url
func WithParentContext ¶
func WithParentContext(parentContext reqContext.Context) RequestOption
WithParentContext encapsulates grpc parent context.
Example ¶
Output: Retrieved channels that peer belongs to
func WithTargetEndpoints ¶
func WithTargetEndpoints(keys ...string) RequestOption
WithTargetEndpoints allows overriding of the target peers for the request. Targets are specified by name or URL, and the SDK will create the underlying peer objects.
func WithTargetFilter ¶
func WithTargetFilter(targetFilter fab.TargetFilter) RequestOption
WithTargetFilter enables a target filter for the request.
Example ¶
Output: Chaincode instantiated
func WithTargets ¶
func WithTargets(targets ...fab.Peer) RequestOption
WithTargets allows overriding of the target peers for the request.
Example ¶
Output: Retrieved channels
func WithTimeout ¶
func WithTimeout(timeoutType fab.TimeoutType, timeout time.Duration) RequestOption
WithTimeout encapsulates key value pairs of timeout type, timeout duration to Options if not provided, default timeout configuration from config will be used
type SaveChannelRequest ¶
type SaveChannelRequest struct { ChannelID string ChannelConfig io.Reader // ChannelConfig data source ChannelConfigPath string // Convenience option to use the named file as ChannelConfig reader SigningIdentities []msp.SigningIdentity // Users that sign channel configuration }
SaveChannelRequest holds parameters for save channel request
type SaveChannelResponse ¶
type SaveChannelResponse struct {
TransactionID fab.TransactionID
}
SaveChannelResponse contains response parameters for save channel
type UpgradeCCRequest ¶
type UpgradeCCRequest struct { Name string Path string Version string Args [][]byte Policy *common.SignaturePolicyEnvelope CollConfig []*common.CollectionConfig }
UpgradeCCRequest contains upgrade chaincode request parameters
type UpgradeCCResponse ¶
type UpgradeCCResponse struct {
TransactionID fab.TransactionID
}
UpgradeCCResponse contains response parameters for upgrade chaincode