config

package
v5.1.6-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockChainNetworkFileName      = "resources/blockchain_network_config.json"
	EthereumJsonRpcHTTPEndpointKey = "ethereum_json_rpc_http_endpoint"
	EthereumJsonRpcWSEndpointKey   = "ethereum_json_rpc_ws_endpoint"
	NetworkId                      = "network_id"
	RegistryAddressKey             = "registry_address_key"
)
View Source
const (
	AllowedUserFlag           = "allowed_user_flag"
	AllowedUserAddresses      = "allowed_user_addresses"
	AuthenticationAddresses   = "authentication_addresses"
	AutoSSLDomainKey          = "auto_ssl_domain"
	AutoSSLCacheDirKey        = "auto_ssl_cache_dir"
	BlockchainEnabledKey      = "blockchain_enabled"
	BlockChainNetworkSelected = "blockchain_network_selected"
	BurstSize                 = "burst_size"
	ConfigPathKey             = "config_path"
	DaemonGroupName           = "daemon_group_name"
	DaemonTypeKey             = "daemon_type"
	DaemonEndPoint            = "daemon_end_point"
	ExecutablePathKey         = "executable_path"
	EnableDynamicPricing      = "enable_dynamic_pricing"
	IpfsEndPoint              = "ipfs_end_point"
	IpfsTimeout               = "ipfs_timeout"
	LogKey                    = "log"
	MaxMessageSizeInMB        = "max_message_size_in_mb"
	MeteringEnabled           = "metering_enabled"
	// ModelMaintenanceEndPoint This is for grpc server end point for Model Maintenance like Create, update, delete, status check
	ModelMaintenanceEndPoint = "model_maintenance_endpoint"
	// ModelTrainingEndpoint This is for directing any training calls on Models, as training calls are heavy on resources
	ModelTrainingEndpoint          = "model_training_endpoint"
	ModelTrainingEnabled           = "model_training_enabled"
	OrganizationId                 = "organization_id"
	ServiceId                      = "service_id"
	PassthroughEnabledKey          = "passthrough_enabled"
	PassthroughEndpointKey         = "passthrough_endpoint"
	ServiceCredentialsKey          = "service_credentials"
	RateLimitPerMinute             = "rate_limit_per_minute"
	SSLCertPathKey                 = "ssl_cert"
	SSLKeyPathKey                  = "ssl_key"
	PaymentChannelCertPath         = "payment_channel_cert_path"
	PaymentChannelCaPath           = "payment_channel_ca_path"
	PaymentChannelKeyPath          = "payment_channel_key_path"
	PaymentChannelStorageTypeKey   = "payment_channel_storage_type"
	PaymentChannelStorageClientKey = "payment_channel_storage_client"
	PaymentChannelStorageServerKey = "payment_channel_storage_server"
	//configs for Daemon Monitoring and Notification
	AlertsEMail                 = "alerts_email"
	HeartbeatServiceEndpoint    = "heartbeat_svc_end_point"
	MeteringEndPoint            = "metering_end_point"
	PvtKeyForMetering           = "pvt_key_for_metering"
	NotificationServiceEndpoint = "notification_svc_end_point"
	ServiceHeartbeatType        = "service_heartbeat_type"
	TokenExpiryInMinutes        = "token_expiry_in_minutes"
	TokenSecretKey              = "token_secret_key"
	BlockchainProviderApiKey    = "blockchain_provider_api_key"
	FreeCallsUsers              = "free_calls_users"

	MinimumConfigJson string = `` /* 457-byte string literal not displayed */

)
View Source
const DefaultDaemonConfigurationSchema = `` /* 1646-byte string literal not displayed */

Variables

View Source
var DisplayKeys = map[string]bool{
	strings.ToUpper(AllowedUserFlag):                true,
	strings.ToUpper(AllowedUserAddresses):           true,
	strings.ToUpper(AuthenticationAddresses):        true,
	strings.ToUpper(AutoSSLDomainKey):               true,
	strings.ToUpper(AutoSSLCacheDirKey):             true,
	strings.ToUpper(BlockchainEnabledKey):           true,
	strings.ToUpper(BlockChainNetworkSelected):      true,
	strings.ToUpper(BurstSize):                      true,
	strings.ToUpper(ConfigPathKey):                  true,
	strings.ToUpper(DaemonGroupName):                true,
	strings.ToUpper(DaemonTypeKey):                  true,
	strings.ToUpper(DaemonEndPoint):                 true,
	strings.ToUpper(ExecutablePathKey):              true,
	strings.ToUpper(IpfsEndPoint):                   true,
	strings.ToUpper(IpfsTimeout):                    true,
	strings.ToUpper(LogKey):                         true,
	strings.ToUpper(MaxMessageSizeInMB):             true,
	strings.ToUpper(MeteringEnabled):                true,
	strings.ToUpper(OrganizationId):                 true,
	strings.ToUpper(ServiceId):                      true,
	strings.ToUpper(PassthroughEnabledKey):          true,
	strings.ToUpper(PassthroughEndpointKey):         true,
	strings.ToUpper(RateLimitPerMinute):             true,
	strings.ToUpper(SSLCertPathKey):                 true,
	strings.ToUpper(SSLKeyPathKey):                  true,
	strings.ToUpper(PaymentChannelCertPath):         true,
	strings.ToUpper(PaymentChannelCaPath):           true,
	strings.ToUpper(PaymentChannelKeyPath):          true,
	strings.ToUpper(PaymentChannelStorageTypeKey):   true,
	strings.ToUpper(PaymentChannelStorageClientKey): true,
	strings.ToUpper(PaymentChannelStorageServerKey): true,
	strings.ToUpper(AlertsEMail):                    true,
	strings.ToUpper(HeartbeatServiceEndpoint):       true,
	strings.ToUpper(MeteringEndPoint):               true,
	strings.ToUpper(NotificationServiceEndpoint):    true,
	strings.ToUpper(ServiceHeartbeatType):           true,
}

Functions

func CheckVersionOfDaemon

func CheckVersionOfDaemon() (message string, err error)

This function is called to see if the current daemon is on the latest version , if it is not, indicate this to the user when the daemon starts.

func ConvertStructToJSON

func ConvertStructToJSON(payLoad any) ([]byte, error)

ConvertStructToJSON converts the passed datastructure to a JSON

func Get

func Get(key string) any

func GetBigInt

func GetBigInt(key string) *big.Int

func GetBigIntFromViper

func GetBigIntFromViper(config *viper.Viper, key string) (value *big.Int, err error)

func GetBlockChainHTTPEndPoint

func GetBlockChainHTTPEndPoint() string

Get the blockchain endpoint associated with the Network selected

func GetBlockChainWSEndPoint

func GetBlockChainWSEndPoint() string

func GetBool

func GetBool(key string) bool

func GetBuildTime

func GetBuildTime() string

func GetDuration

func GetDuration(key string) time.Duration

func GetFreeCallsCount

func GetFreeCallsCount(userID string) (countFreeCallsAllowed int)

func GetInt

func GetInt(key string) int

func GetLatestDaemonVersion

func GetLatestDaemonVersion() (version string, err error)

func GetNetworkId

func GetNetworkId() string

Get the Network ID associated with the network selected

func GetRegistryAddress

func GetRegistryAddress() string

Get the Registry address of the contract

func GetSha1Revision

func GetSha1Revision() string

func GetString

func GetString(key string) string

func GetStringMap

func GetStringMap(key string) map[string]any

func GetStringSlice

func GetStringSlice(key string) []string

func GetVersionTag

func GetVersionTag() string

func IsAllowedUser

func IsAllowedUser(address *common.Address) bool

func IsValidUrl

func IsValidUrl(urlToTest string) bool

isValidUrl tests a string to determine if it is a url or not.

func LoadConfig

func LoadConfig(configFile string) error

func LogConfig

func LogConfig()

func NewJsonConfigFromString

func NewJsonConfigFromString(config string) *viper.Viper

NewJsonConfigFromString for tests

func ReadConfigFromJsonString

func ReadConfigFromJsonString(config *viper.Viper, json string) error

ReadConfigFromJsonString function reads settigs from json string to the config instance. String should contain valid JSON config.

func ReadFromFile

func ReadFromFile(filename string) ([]byte, error)

Read the file given file, if the file is not found ,then return back an error

func SetAllowedUsers

func SetAllowedUsers() (err error)

Set the list of allowed users

func SetDefaultFromConfig

func SetDefaultFromConfig(config *viper.Viper, defaults *viper.Viper)

SetDefaultFromConfig sets all settings from defaults as default values to the config.

func SetVip

func SetVip(newVip *viper.Viper)

SetVip allows setting a new Viper instance. This is useful for testing, where you may want to change the configuration.

func SubWithDefault

func SubWithDefault(config *viper.Viper, key string) *viper.Viper

SubWithDefault returns sub-config by keys including configuration defaults values. It returns nil if no such key. It is analog of the viper.Sub() function. This is workaround for the issue https://github.com/spf13/viper/issues/559

func Validate

func Validate() error

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail validates an input email

func ValidateEndpoints

func ValidateEndpoints(daemonEndpoint string, passthroughEndpoint string) error

func Vip

func Vip() *viper.Viper

func WriteConfig

func WriteConfig(configFile string) error

Types

type ConfigurationDetails

type ConfigurationDetails struct {
	Name          string //the key of the attribute becomes the Value of the Name
	Mandatory     bool   `json:"mandatory"`
	DefaultValue  string `json:"value"`
	Description   string `json:"description"`
	Type          string `json:"type"`
	Editable      bool   `json:"editable"`
	RestartDaemon bool   `json:"restart_daemon"`
	Section       string `json:"section"`
}

Used to map the attribute values to a struct

func GetConfigurationSchema

func GetConfigurationSchema() ([]ConfigurationDetails, error)

type GitTags

type GitTags struct {
	TagName string `json:"tag_name"`
}

type NetworkSelected

type NetworkSelected struct {
	NetworkName                 string
	EthereumJSONRPCHTTPEndpoint string
	EthereumJSONRPCWSEndpoint   string
	NetworkId                   string
	RegistryAddressKey          string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL