config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config contains all the configuration to start a Hazelcast instance.

Index

Constants

View Source
const (
	// DefaultPrefetchCount is the default value for PrefetchCount().
	DefaultPrefetchCount = 100

	// DefaultPrefetchValidityMillis is the default value for PrefetchValidityMillis().
	DefaultPrefetchValidityMillis = 600000

	// MaximumPrefetchCount is the maximum value for prefetch count.
	// The reason to limit the prefetch count is that a single call to 'FlakeIDGenerator.NewID()` might
	// be blocked if the future allowance is exceeded: we want to avoid a single call for large batch to block
	// another call for small batch.
	MaximumPrefetchCount = 100000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudConfig

type CloudConfig struct {
	// contains filtered or unexported fields
}

CloudConfig is used as hazelcast.cloud configuration to let the client connect the cluster via hazelcast.cloud.

func NewCloudConfig

func NewCloudConfig() *CloudConfig

NewCloudConfig returns a cloud config. CloudConfig is used as hazelcast.cloud configuration to let the client connect the cluster via hazelcast.cloud.

func (*CloudConfig) DiscoveryToken

func (cc *CloudConfig) DiscoveryToken() string

DiscoveryToken returns the discovery token.

func (*CloudConfig) IsEnabled

func (cc *CloudConfig) IsEnabled() bool

IsEnabled returns true if client cloud discovery is enabled, false otherwise.

func (*CloudConfig) SetDiscoveryToken

func (cc *CloudConfig) SetDiscoveryToken(discoveryToken string)

SetDiscoveryToken sets the discovery token as the given token.

func (*CloudConfig) SetEnabled

func (cc *CloudConfig) SetEnabled(enabled bool)

SetEnabled sets the enabled field of cloud config.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the main configuration to setup a Hazelcast client.

func New

func New() *Config

New returns a new Config with default configuration.

func (*Config) AddFlakeIDGeneratorConfig

func (c *Config) AddFlakeIDGeneratorConfig(config *FlakeIDGeneratorConfig)

AddFlakeIDGeneratorConfig adds the given config to the configurations map.

func (*Config) AddLifecycleListener

func (c *Config) AddLifecycleListener(listener interface{})

AddLifecycleListener adds a lifecycle listener.

func (*Config) AddMembershipListener

func (c *Config) AddMembershipListener(listener interface{})

AddMembershipListener adds a membership listener.

func (*Config) AddReliableTopicConfig

func (c *Config) AddReliableTopicConfig(config *ReliableTopicConfig)

AddReliableTopicConfig adds the given reliable topic config to reliable topic configurations.

func (*Config) ClientName

func (c *Config) ClientName() string

ClientName returns the client name with this config.

func (*Config) GetFlakeIDGeneratorConfig

func (c *Config) GetFlakeIDGeneratorConfig(name string) *FlakeIDGeneratorConfig

GetFlakeIDGeneratorConfig returns the FlakeIDGeneratorConfig for the given name, creating one if necessary and adding it to the map of known configurations. If no configuration is found with the given name it will create a new one with the default Config.

func (*Config) GetReliableTopicConfig

func (c *Config) GetReliableTopicConfig(name string) *ReliableTopicConfig

GetReliableTopicConfig returns the reliable topic config for this client.

func (*Config) GroupConfig

func (c *Config) GroupConfig() *GroupConfig

GroupConfig returns GroupConfig.

func (*Config) LifecycleListeners

func (c *Config) LifecycleListeners() []interface{}

LifecycleListeners returns lifecycle listeners.

func (*Config) LoadBalancer

func (c *Config) LoadBalancer() core.LoadBalancer

LoadBalancer returns loadBalancer for this client. If it is not set, this will return nil.

func (*Config) LoggerConfig

func (c *Config) LoggerConfig() *LoggerConfig

LoggerConfig returns loggerConfig.

func (*Config) MembershipListeners

func (c *Config) MembershipListeners() []interface{}

MembershipListeners returns membership listeners.

func (*Config) NetworkConfig

func (c *Config) NetworkConfig() *NetworkConfig

NetworkConfig returns NetworkConfig.

func (*Config) Properties

func (c *Config) Properties() Properties

Properties returns the properties of the config.

func (*Config) SecurityConfig

func (c *Config) SecurityConfig() *SecurityConfig

SecurityConfig returns the security config for this client.

func (*Config) SerializationConfig

func (c *Config) SerializationConfig() *serialization.Config

SerializationConfig returns SerializationConfig.

func (*Config) SetClientName

func (c *Config) SetClientName(name string)

SetClientName sets the client name.

func (*Config) SetGroupConfig

func (c *Config) SetGroupConfig(groupConfig *GroupConfig)

SetGroupConfig sets the GroupConfig.

func (*Config) SetLoadBalancer

func (c *Config) SetLoadBalancer(loadBalancer core.LoadBalancer)

SetLoadBalancer sets loadBalancer as the given one.

func (*Config) SetNetworkConfig

func (c *Config) SetNetworkConfig(networkConfig *NetworkConfig)

SetNetworkConfig sets the NetworkConfig.

func (*Config) SetProperty

func (c *Config) SetProperty(name string, value string)

SetProperty sets a new pair of property as (name, value).

func (*Config) SetSecurityConfig

func (c *Config) SetSecurityConfig(securityConfig *SecurityConfig)

SetSecurityConfig sets the security config for this client.

func (*Config) SetSerializationConfig

func (c *Config) SetSerializationConfig(serializationConfig *serialization.Config)

SetSerializationConfig sets the serialization config.

type FlakeIDGeneratorConfig

type FlakeIDGeneratorConfig struct {
	// contains filtered or unexported fields
}

FlakeIDGeneratorConfig contains the configuration for 'FlakeIDGenerator' proxy.

func NewFlakeIDGeneratorConfig

func NewFlakeIDGeneratorConfig(name string) *FlakeIDGeneratorConfig

NewFlakeIDGeneratorConfig returns a new FlakeIDGeneratorConfig with the given name and default parameters.

func NewFlakeIDGeneratorConfigWithParameters

func NewFlakeIDGeneratorConfigWithParameters(name string, prefetchCount int32,
	prefetchValidityMillis int64) *FlakeIDGeneratorConfig

NewFlakeIDGeneratorConfigWithParameters returns a new FlakeIDGeneratorConfig with the given name, prefetchCount and prefetchValidityMillis.

func (*FlakeIDGeneratorConfig) Name

func (igc *FlakeIDGeneratorConfig) Name() string

Name returns the name.

func (*FlakeIDGeneratorConfig) PrefetchCount

func (igc *FlakeIDGeneratorConfig) PrefetchCount() int32

PrefetchCount returns the prefetchCount.

func (*FlakeIDGeneratorConfig) PrefetchValidityMillis

func (igc *FlakeIDGeneratorConfig) PrefetchValidityMillis() int64

PrefetchValidityMillis returns the prefetchValidityMillis

func (*FlakeIDGeneratorConfig) SetName

func (igc *FlakeIDGeneratorConfig) SetName(name string)

SetName sets the name as the given name. Name must not be set after flake id config is added to config.

func (*FlakeIDGeneratorConfig) SetPrefetchCount

func (igc *FlakeIDGeneratorConfig) SetPrefetchCount(prefetchCount int32)

SetPrefetchCount sets prefetchCount as the given value. prefetch count should be between 0 and MaximumPrefetchCount, otherwise it will panic.

func (*FlakeIDGeneratorConfig) SetPrefetchValidityMillis

func (igc *FlakeIDGeneratorConfig) SetPrefetchValidityMillis(prefetchValidityMillis int64)

SetPrefetchValidityMillis sets the prefetchValidityMillis as the given value.

type GroupConfig

type GroupConfig struct {
	// contains filtered or unexported fields
}

GroupConfig contains the configuration for Hazelcast groups. With groups it is possible to create multiple clusters where each cluster has its own group and doesn't interfere with other clusters.

func NewGroupConfig

func NewGroupConfig() *GroupConfig

NewGroupConfig returns a new GroupConfig with default group name and password.

func (*GroupConfig) Name

func (gc *GroupConfig) Name() string

Name returns the group name of the group.

func (*GroupConfig) Password

func (gc *GroupConfig) Password() string

Password returns the group password of the group.

func (*GroupConfig) SetName

func (gc *GroupConfig) SetName(name string)

SetName sets the group name of the group.

func (*GroupConfig) SetPassword

func (gc *GroupConfig) SetPassword(password string) *GroupConfig

SetPassword sets the group password of the group. SetPassword returns the configured GroupConfig for chaining.

type LoggerConfig

type LoggerConfig struct {
	// contains filtered or unexported fields
}

LoggerConfig is used for configuring client's logging.

func NewLoggerConfig

func NewLoggerConfig() *LoggerConfig

NewLoggerConfig returns a LoggerConfig with default logger.

func (*LoggerConfig) Logger

func (l *LoggerConfig) Logger() logger.Logger

Logger returns the loggerConfig's logger.

func (*LoggerConfig) SetLogger

func (l *LoggerConfig) SetLogger(logger logger.Logger)

SetLogger sets the loggerConfig's logger as the given one. If this method is called, LoggingLevel property wont be used, instead Level should be set by user.

type NetworkConfig

type NetworkConfig struct {
	// contains filtered or unexported fields
}

NetworkConfig contains network related configuration parameters.

func NewNetworkConfig

func NewNetworkConfig() *NetworkConfig

NewNetworkConfig returns a new NetworkConfig with default configuration.

func (*NetworkConfig) AddAddress

func (nc *NetworkConfig) AddAddress(addresses ...string)

AddAddress adds given addresses to candidate address list that client will use to establish initial connection.

func (*NetworkConfig) Addresses

func (nc *NetworkConfig) Addresses() []string

Addresses returns the slice of candidate addresses that client will use to establish initial connection.

func (*NetworkConfig) CloudConfig

func (nc *NetworkConfig) CloudConfig() *CloudConfig

CloudConfig returns the cloud config.

func (*NetworkConfig) ConnectionAttemptLimit

func (nc *NetworkConfig) ConnectionAttemptLimit() int32

ConnectionAttemptLimit returns connection attempt limit.

func (*NetworkConfig) ConnectionAttemptPeriod

func (nc *NetworkConfig) ConnectionAttemptPeriod() time.Duration

ConnectionAttemptPeriod returns the period for the next attempt to find a member to connect.

func (*NetworkConfig) ConnectionTimeout

func (nc *NetworkConfig) ConnectionTimeout() time.Duration

ConnectionTimeout returns the timeout value for nodes to accept client connection requests.

func (*NetworkConfig) IsRedoOperation

func (nc *NetworkConfig) IsRedoOperation() bool

IsRedoOperation returns true if redo operations are enabled.

func (*NetworkConfig) IsSmartRouting

func (nc *NetworkConfig) IsSmartRouting() bool

IsSmartRouting returns true if client is smart.

func (*NetworkConfig) SSLConfig

func (nc *NetworkConfig) SSLConfig() *SSLConfig

SSLConfig returns SSLConfig for this client.

func (*NetworkConfig) SetAddresses

func (nc *NetworkConfig) SetAddresses(addresses []string)

SetAddresses sets given addresses as candidate address list that client will use to establish initial connection.

func (*NetworkConfig) SetCloudConfig

func (nc *NetworkConfig) SetCloudConfig(cloudConfig *CloudConfig)

SetCloudConfig sets the Cloud Config as the given config.

func (*NetworkConfig) SetConnectionAttemptLimit

func (nc *NetworkConfig) SetConnectionAttemptLimit(connectionAttemptLimit int32)

SetConnectionAttemptLimit sets the connection attempt limit. While client is trying to connect initially to one of the members in the addresses slice, all might not be available. Instead of giving up, returning Error and stopping client, it will attempt to retry as much as defined by this parameter.

func (*NetworkConfig) SetConnectionAttemptPeriod

func (nc *NetworkConfig) SetConnectionAttemptPeriod(connectionAttemptPeriod time.Duration)

SetConnectionAttemptPeriod sets the period for the next attempt to find a member to connect

func (*NetworkConfig) SetConnectionTimeout

func (nc *NetworkConfig) SetConnectionTimeout(connectionTimeout time.Duration)

SetConnectionTimeout sets the connection timeout. Setting a timeout of zero disables the timeout feature and is equivalent to block the socket until it connects.

func (*NetworkConfig) SetRedoOperation

func (nc *NetworkConfig) SetRedoOperation(redoOperation bool)

SetRedoOperation sets redoOperation. If true, client will redo the operations that were executing on the server when client recovers the connection after a failure. This can be because of network, or simply because the member died. However it is not clear whether the application is performed or not. For idempotent operations this is harmless, but for non idempotent ones retrying can cause to undesirable effects. Note that the redo can perform on any member.

func (*NetworkConfig) SetSmartRouting

func (nc *NetworkConfig) SetSmartRouting(smartRouting bool)

SetSmartRouting sets smartRouting. If true, client will route the key based operations to owner of the key at the best effort. Note that it uses a cached version of partitionService and doesn't guarantee that the operation will always be executed on the owner. The cached table is updated every 10 seconds. Default value is true.

type Properties

type Properties map[string]string

type ReliableTopicConfig

type ReliableTopicConfig struct {
	// contains filtered or unexported fields
}

ReliableTopicConfig contains the ReliableTopic configuration for a client.

func NewReliableTopicConfig

func NewReliableTopicConfig(name string) *ReliableTopicConfig

NewReliableTopicConfig returns a ReliableTopicConfig with the given name.

func (*ReliableTopicConfig) Name

func (r *ReliableTopicConfig) Name() string

Name returns the name of this config.

func (*ReliableTopicConfig) ReadBatchSize

func (r *ReliableTopicConfig) ReadBatchSize() int32

ReadBatchSize return the readBatchSize of this config.

func (*ReliableTopicConfig) SetReadBatchSize

func (r *ReliableTopicConfig) SetReadBatchSize(readBatchSize int32)

SetReadBatchSize sets the read batch size for this config. The given read batch size should be positive.

func (*ReliableTopicConfig) SetTopicOverloadPolicy

func (r *ReliableTopicConfig) SetTopicOverloadPolicy(policy core.TopicOverloadPolicy)

SetTopicOverloadPolicy sets the TopicOverloadPolicy as the given TopicOverloadPolicy.

func (*ReliableTopicConfig) TopicOverloadPolicy

func (r *ReliableTopicConfig) TopicOverloadPolicy() core.TopicOverloadPolicy

TopicOverloadPolicy returns the TopicOverloadPolicy for this config.

type SSLConfig

type SSLConfig struct {
	*tls.Config
	// contains filtered or unexported fields
}

SSLConfig is SSL configuration for client. SSLConfig has tls.Config embedded in it so that users can set any field of tls config as they wish. SSL config also has some helpers such as SetCaPath, AddClientCertAndKeyPath to make configuration easier for users.

func NewSSLConfig

func NewSSLConfig() *SSLConfig

NewSSLConfig returns SSLConfig.

func (*SSLConfig) AddClientCertAndEncryptedKeyPath

func (sc *SSLConfig) AddClientCertAndEncryptedKeyPath(clientCertPath string, clientPrivateKeyPath string,
	password string) error

AddClientCertAndEncryptedKeyPath decrypts the keyfile with the given password and adds client certificate path and the decrypted client private key to tls config. The files in the given paths must contain PEM encoded data. The key file should have a DEK-info header otherwise an error will be returned. In order to add multiple client certificate-key pairs one should call this function for each of them. If certificates is empty then no certificate will be sent to the server. If this is unacceptable to the server then it may abort the handshake. For mutual authentication at least one client certificate should be added. It returns an error if any of files cannot be loaded.

func (*SSLConfig) AddClientCertAndKeyPath

func (sc *SSLConfig) AddClientCertAndKeyPath(clientCertPath string, clientPrivateKeyPath string) error

AddClientCertAndKeyPath adds client certificate path and client private key path to tls config. The files in the given paths must contain PEM encoded data. In order to add multiple client certificate-key pairs one should call this function for each of them. If certificates is empty then no certificate will be sent to the server. If this is unacceptable to the server then it may abort the handshake. For mutual authentication at least one client certificate should be added. It returns an error if any of files cannot be loaded.

func (*SSLConfig) Enabled

func (sc *SSLConfig) Enabled() bool

Enabled returns true if SSL is enabled, false otherwise.

func (*SSLConfig) SetCaPath

func (sc *SSLConfig) SetCaPath(path string) error

SetCaPath sets CA file path. It returns an error if file cannot be loaded.

func (*SSLConfig) SetEnabled

func (sc *SSLConfig) SetEnabled(enabled bool)

SetEnabled sets enabled field. In order to use SSL connection, this field should be enabled.

type SecurityConfig

type SecurityConfig struct {
	// contains filtered or unexported fields
}

SecurityConfig contains the security configuration for a client.

func (*SecurityConfig) Credentials

func (csc *SecurityConfig) Credentials() security.Credentials

Credentials returns the credentials for this client.

func (*SecurityConfig) SetCredentials

func (csc *SecurityConfig) SetCredentials(credentials security.Credentials)

SetCredentials sets credentials as the given one.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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