Documentation ¶
Index ¶
Constants ¶
View Source
const ( FlagBeJsonRpcEnable = "be.enable" FlagBeJsonRpcAddress = "be.address" FlagBeJsonRpcHttpTimeout = "be.http-timeout" FlagBeJsonRpcHttpIdleTimeout = "be.http-idle-timeout" FlagBeJsonRpcMaxOpenConnection = "be.max-open-connections" FlagBeJsonRpcAllowCORS = "be.allow-cors" )
View Source
const ( // DefaultEnable is the default value for enabling the BE-JSON-RPC server DefaultEnable = false // DefaultJSONRPCAddress is the default address the BE-JSON-RPC server binds to. DefaultJSONRPCAddress = "0.0.0.0:11100" // DefaultHTTPTimeout is the default read/write timeout of the http be-json-rpc server DefaultHTTPTimeout = 30 * time.Second // DefaultHTTPIdleTimeout is the default idle timeout of the http be-json-rpc server DefaultHTTPIdleTimeout = 120 * time.Second // DefaultMaxOpenConnections represents the amount of open connections (unlimited = 0) DefaultMaxOpenConnections = 0 // DefaultAllowCORS represents the default value for allowing CORS requests DefaultAllowCORS = true )
View Source
const ( DefaultConfigDirName = "config" DefaultConfigName = "be-json-rpc" DefaultConfigFileName = DefaultConfigName + ".toml" )
Variables ¶
This section is empty.
Functions ¶
func AddBeJsonRpcFlags ¶
AddBeJsonRpcFlags add Block Explorer Json-RPC flags into the cmd Legacy TODO BE: call this to register flags
func EnsureRoot ¶
func EnsureRoot(rootDir string, defaultConfig *BeJsonRpcConfig)
EnsureRoot creates the root, config, and data directories if they don't exist, and panics if it fails.
func WriteConfigFile ¶
func WriteConfigFile(configFilePath string, config *BeJsonRpcConfig)
WriteConfigFile renders config using the template and writes it to configFilePath.
Types ¶
type BeJsonRpcConfig ¶
type BeJsonRpcConfig struct { // Enable defines if the Be Json RPC server should be enabled. Enable bool `mapstructure:"enable"` // Address defines the HTTP server to listen on Address string `mapstructure:"address"` // HTTPTimeout is the http read/write timeout of Block Explorer Json-RPC server. HTTPTimeout time.Duration `mapstructure:"http-timeout"` // HTTPIdleTimeout is the http idle timeout of Block Explorer Json-RPC server. HTTPIdleTimeout time.Duration `mapstructure:"http-idle-timeout"` // MaxOpenConnections sets the maximum number of simultaneous connections // for the server listener. MaxOpenConnections int `mapstructure:"max-open-connections"` // AllowCORS defines if the server should allow CORS requests. Allowed by default. AllowCORS bool `mapstructure:"allow-cors"` }
BeJsonRpcConfig defines configuration for the Block Explorer Json-RPC server.
func DefaultBeJsonRpcConfig ¶
func DefaultBeJsonRpcConfig() *BeJsonRpcConfig
DefaultBeJsonRpcConfig returns Block Explorer JSON-RPC API config with default values
func GetConfig ¶
func GetConfig(v *viper.Viper) (BeJsonRpcConfig, error)
GetConfig returns a fully parsed BeJsonRpcConfig object.
func (*BeJsonRpcConfig) GetViperConfig ¶
func (c *BeJsonRpcConfig) GetViperConfig(cmd *cobra.Command, homeDir string) error
GetViperConfig reads configuration parameters from Viper instance.
func (BeJsonRpcConfig) Validate ¶
func (c BeJsonRpcConfig) Validate() error
Validate returns an error if the JSON-RPC configuration fields are invalid.
Click to show internal directories.
Click to hide internal directories.