Documentation ¶
Index ¶
- Constants
- Variables
- func RunAndCleanup(cmd *cobra.Command, args []string, constructor CommandConstructor) (err error)
- type CertReloader
- type Command
- type CommandConstructor
- type Components
- func (components *Components) AllowedUserPaymentHandler() handler.PaymentHandler
- func (components *Components) AtomicStorage() storage.AtomicStorage
- func (components *Components) Blockchain() *blockchain.Processor
- func (components *Components) ChannelBroadcast() *configuration_service.MessageBroadcaster
- func (components *Components) Close()
- func (components *Components) ConfigurationService() *configuration_service.ConfigurationService
- func (components *Components) DaemonHeartBeat() (service *metrics.DaemonHeartbeat)
- func (components *Components) EscrowPaymentHandler() handler.PaymentHandler
- func (components *Components) EtcdClient() *etcddb.EtcdClient
- func (components *Components) EtcdServer() *etcddb.EtcdServer
- func (components *Components) FreeCallLockerStorage() *storage.PrefixedAtomicStorage
- func (components *Components) FreeCallPaymentHandler() handler.PaymentHandler
- func (components *Components) FreeCallStateService() (service escrow.FreeCallStateServiceServer)
- func (components *Components) FreeCallUserService() escrow.FreeCallUserService
- func (components *Components) FreeCallUserStorage() *escrow.FreeCallUserStorage
- func (components *Components) GrpcInterceptor() grpc.StreamServerInterceptor
- func (components *Components) GrpcPaymentValidationInterceptor() grpc.StreamServerInterceptor
- func (components *Components) LockerStorage() *storage.PrefixedAtomicStorage
- func (components *Components) MPESpecificStorage() *storage.PrefixedAtomicStorage
- func (components *Components) ModelService() training.ModelServer
- func (components *Components) ModelStorage() *training.ModelStorage
- func (components *Components) ModelUserStorage() *training.ModelUserStorage
- func (components *Components) OrganizationMetaData() *blockchain.OrganizationMetaData
- func (components *Components) PaymentChannelService() escrow.PaymentChannelService
- func (components *Components) PaymentChannelStateService() (service escrow.PaymentChannelStateServiceServer)
- func (components *Components) PaymentStorage() *escrow.PaymentStorage
- func (components *Components) PrePaidPaymentHandler() handler.PaymentHandler
- func (components *Components) PrePaidService() escrow.PrePaidService
- func (components *Components) PrepaidUserStorage() storage.TypedAtomicStorage
- func (components *Components) PricingStrategy() *pricing.PricingStrategy
- func (components *Components) ProviderControlService() (service escrow.ProviderControlServiceServer)
- func (components *Components) ServiceMetaData() *blockchain.ServiceMetadata
- func (components *Components) TokenManager() token.Manager
- func (components *Components) TokenService() escrow.TokenServiceServer
- type ListVersionCommand
- type VerifyMeteringResponse
Constants ¶
const ( UnlockChannelFlag = "unlock" UserIdFlag = "user-id" )
Variables ¶
var ChannelCmd = &cobra.Command{ Use: "channel", Short: "Manage operations on payment channels", Long: "allows us to perform operations on channels with given channel ID." + " User can use 'snetd channel --unlock {channelID}' command to unlock the channel manually.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newChannelCommand) }, }
ListChannelsCmd shows list of channels from shared storage
var FreeCallUserCmd = &cobra.Command{
Use: "freecall",
Short: "Manage operations on free call users",
Long: "List commands prints a list of all free call users for the given service," +
"reset will set the counter to zero on free calls used, " +
"unlock will release the lock on the given user ",
}
var FreeCallUserResetCmd = &cobra.Command{ Use: "reset", Short: "Reset the count on free calls used for the given user to zero", Long: "User can use 'snetd freecall reset -u {user-id}' command to reset the free call used of this User manually.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newFreeCallResetCountCommand) }, }
var FreeCallUserUnLockCmd = &cobra.Command{ Use: "unlock", Short: "Unlock a free call user", Long: "allows us to perform operations on free call users with given user_id(email_id)." + " User can use 'snetd freecall unlock -u {userId}' command to unlock the User manually.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newFreeCallUserUnLockCommandCommand) }, }
var InitCmd = &cobra.Command{ Use: "init", Short: "Write default configuration to file", Long: "Use this command to create simple configuration file. Then update the file with your settings.", Run: func(cmd *cobra.Command, args []string) { var err error var configFile = cmd.Flags().Lookup("config").Value.String() if isFileExist(configFile) { fmt.Println("ERROR: such configFile already exists, please remove file first or rename file:", configFile) os.Exit(-1) } err = os.WriteFile(configFile, []byte(config.MinimumConfigJson), 0666) if err != nil { fmt.Println("ERROR: Cannot write configuration rename file:", configFile) os.Exit(-1) } fmt.Println("Writing basic configuration to the file:", configFile) }, }
var InitFullCmd = &cobra.Command{ Use: "init-full", Short: "Write full default configuration to file", Long: "Use this command to create full default configuration file. Then update the file with your settings.", Run: func(cmd *cobra.Command, args []string) { var err error var configFile = cmd.Flags().Lookup("config").Value.String() if isFileExist(configFile) { fmt.Println("ERROR: such configFile already exists, please remove file first or rename file:", configFile) os.Exit(-1) } err = config.WriteConfig(configFile) if err != nil { fmt.Println("ERROR: Cannot write full configuration to file:", configFile) os.Exit(-1) } fmt.Println("Writing full default configuration to the file:", configFile) }, }
var ListChannelsCmd = &cobra.Command{ Use: "channels", Short: "List payment channels", Long: "List payment channels for which at least on payment was received." + " User can use 'snetd claim --channel-id' command to claim funds from channel.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListChannelsCommand) }, }
ListChannelsCmd shows list of channels from shared storage
var ListClaimsCmd = &cobra.Command{ Use: "claims", Short: "List payments which are not written to blockchain yet", Long: "List payments which are in progress state and not written" + " to the blockchain.", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListClaimsCommand) }, }
ListClaimsCmd shows list of channels from shared storage
var ListCmd = &cobra.Command{
Use: "list",
Short: "List channels, claims in progress, etc",
Long: "List command prints lists of objects from the shared storage; each object type has separate subcommand",
}
ListCmd command to list channels, claims, etc
var ListFreeCallUserCmd = &cobra.Command{ Use: "list", Short: "List of all free call users", Long: "List all users who have availed free calls to your service", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListFreeCallUserCommand) }, }
ListFreeCallUserCmd displays all the users of free call for the given service and group
var RootCmd = &cobra.Command{ Use: "snetd", Run: func(cmd *cobra.Command, args []string) { if command, _, err := cmd.Find(args); err != nil && command != nil { command.Execute() } else { ServeCmd.Run(cmd, args) } }, }
var ServeCmd = &cobra.Command{ Use: "serve", Short: "Is the default option which starts the Daemon.", Run: func(cmd *cobra.Command, args []string) { var err error components := InitComponents(cmd) defer components.Close() logger.Initialize() config.LogConfig() etcdServer := components.EtcdServer() if etcdServer == nil { zap.L().Info("Etcd server is disabled in the config file.") } var d daemon d, err = newDaemon(components) if err != nil { zap.L().Fatal("Unable to initialize daemon", zap.Error(err)) } d.start() defer d.stop() if d.components.etcdClient != nil && d.components.etcdClient.IsHotReloadEnabled() { contractEventLister := contractListener.ContractEventListener{ BlockchainProcessor: &d.blockProc, CurrentOrganizationMetaData: components.OrganizationMetaData(), CurrentEtcdClient: components.EtcdClient(), } go contractEventLister.ListenOrganizationMetadataChanging() } sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) <-sigChan zap.L().Debug("Exiting") }, }
var VersionCmd = &cobra.Command{ Use: "version", Short: "List the current version of the Daemon.", Long: "To check the current version of the Daemon, the sha1 revision and the time the Binary was built User can use `snetd version`", RunE: func(cmd *cobra.Command, args []string) error { return RunAndCleanup(cmd, args, newListVersionCommand) }, }
Shows the current version of the Daemons Version tag: v0.1.4-181-g2fd9f04 was build on: 2019-03-19_13:52:58 with sha1 revision from github: 2fd9f04bfb279aaf66291cd6bd2ca734fd4f70b5
Functions ¶
func RunAndCleanup ¶
func RunAndCleanup(cmd *cobra.Command, args []string, constructor CommandConstructor) (err error)
RunAndCleanup initializes components, constructs command, runs it, cleanups components and returns results
Types ¶
type CertReloader ¶
type CertReloader struct { CertFile string // path to the x509 certificate for https KeyFile string // path to the x509 private key matching // contains filtered or unexported fields }
func (*CertReloader) GetCertificate ¶
func (cr *CertReloader) GetCertificate() *tls.Certificate
func (*CertReloader) Listen ¶
func (cr *CertReloader) Listen()
type CommandConstructor ¶
type CommandConstructor func(cmd *cobra.Command, args []string, components *Components) (command Command, err error)
CommandConstructor creates new command using command line arguments, cobra context and initialized components
type Components ¶
type Components struct {
// contains filtered or unexported fields
}
func InitComponents ¶
func InitComponents(cmd *cobra.Command) (components *Components)
func (*Components) AllowedUserPaymentHandler ¶
func (components *Components) AllowedUserPaymentHandler() handler.PaymentHandler
func (*Components) AtomicStorage ¶
func (components *Components) AtomicStorage() storage.AtomicStorage
create new PrefixedStorage using /<network_name> as a prefix, use this storage as base for other storages (i.e. return it from GetAtomicStorage of components.go); this guarantees that storages for different networks never intersect
func (*Components) Blockchain ¶
func (components *Components) Blockchain() *blockchain.Processor
func (*Components) ChannelBroadcast ¶
func (components *Components) ChannelBroadcast() *configuration_service.MessageBroadcaster
func (*Components) Close ¶
func (components *Components) Close()
func (*Components) ConfigurationService ¶
func (components *Components) ConfigurationService() *configuration_service.ConfigurationService
func (*Components) DaemonHeartBeat ¶
func (components *Components) DaemonHeartBeat() (service *metrics.DaemonHeartbeat)
func (*Components) EscrowPaymentHandler ¶
func (components *Components) EscrowPaymentHandler() handler.PaymentHandler
func (*Components) EtcdClient ¶
func (components *Components) EtcdClient() *etcddb.EtcdClient
func (*Components) EtcdServer ¶
func (components *Components) EtcdServer() *etcddb.EtcdServer
func (*Components) FreeCallLockerStorage ¶
func (components *Components) FreeCallLockerStorage() *storage.PrefixedAtomicStorage
func (*Components) FreeCallPaymentHandler ¶
func (components *Components) FreeCallPaymentHandler() handler.PaymentHandler
func (*Components) FreeCallStateService ¶
func (components *Components) FreeCallStateService() (service escrow.FreeCallStateServiceServer)
func (*Components) FreeCallUserService ¶
func (components *Components) FreeCallUserService() escrow.FreeCallUserService
func (*Components) FreeCallUserStorage ¶
func (components *Components) FreeCallUserStorage() *escrow.FreeCallUserStorage
func (*Components) GrpcInterceptor ¶
func (components *Components) GrpcInterceptor() grpc.StreamServerInterceptor
Add a chain of interceptors
func (*Components) GrpcPaymentValidationInterceptor ¶
func (components *Components) GrpcPaymentValidationInterceptor() grpc.StreamServerInterceptor
func (*Components) LockerStorage ¶
func (components *Components) LockerStorage() *storage.PrefixedAtomicStorage
func (*Components) MPESpecificStorage ¶
func (components *Components) MPESpecificStorage() *storage.PrefixedAtomicStorage
add new component MPESpecificStorage; it is also instance of PrefixedStorage using /<mpe_contract_address> as a prefix; as it is also based on storage from previous item the effective prefix is /<network_id>/<mpe_contract_address>; this guarantees that storages which are specific for MPE contract version don't intersect; use MPESpecificStorage as base for PaymentChannelStorage, PaymentStorage, LockStorage for channels;
func (*Components) ModelService ¶
func (components *Components) ModelService() training.ModelServer
func (*Components) ModelStorage ¶
func (components *Components) ModelStorage() *training.ModelStorage
func (*Components) ModelUserStorage ¶
func (components *Components) ModelUserStorage() *training.ModelUserStorage
func (*Components) OrganizationMetaData ¶
func (components *Components) OrganizationMetaData() *blockchain.OrganizationMetaData
func (*Components) PaymentChannelService ¶
func (components *Components) PaymentChannelService() escrow.PaymentChannelService
func (*Components) PaymentChannelStateService ¶
func (components *Components) PaymentChannelStateService() (service escrow.PaymentChannelStateServiceServer)
func (*Components) PaymentStorage ¶
func (components *Components) PaymentStorage() *escrow.PaymentStorage
func (*Components) PrePaidPaymentHandler ¶
func (components *Components) PrePaidPaymentHandler() handler.PaymentHandler
func (*Components) PrePaidService ¶
func (components *Components) PrePaidService() escrow.PrePaidService
func (*Components) PrepaidUserStorage ¶
func (components *Components) PrepaidUserStorage() storage.TypedAtomicStorage
func (*Components) PricingStrategy ¶
func (components *Components) PricingStrategy() *pricing.PricingStrategy
func (*Components) ProviderControlService ¶
func (components *Components) ProviderControlService() (service escrow.ProviderControlServiceServer)
func (*Components) ServiceMetaData ¶
func (components *Components) ServiceMetaData() *blockchain.ServiceMetadata
func (*Components) TokenManager ¶
func (components *Components) TokenManager() token.Manager
func (*Components) TokenService ¶
func (components *Components) TokenService() escrow.TokenServiceServer
type ListVersionCommand ¶
type ListVersionCommand struct { }
func (*ListVersionCommand) Run ¶
func (command *ListVersionCommand) Run() (err error)
type VerifyMeteringResponse ¶
type VerifyMeteringResponse struct {
Data string `json:"data"`
}