config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxSendMsgSize         = 100 * 1024 * 1024
	MaxRecvMsgSize         = 100 * 1024 * 1024
	DefaultKeepaliveConfig = &KeepaliveConfig{
		ClientInterval:    time.Duration(1) * time.Minute,
		ClientTimeout:     time.Duration(20) * time.Second,
		ServerInterval:    time.Duration(2) * time.Hour,
		ServerTimeout:     time.Duration(20) * time.Second,
		ServerMinInterval: time.Duration(1) * time.Minute,
	}
	// strong TLS cipher suites
	DefaultTLSCipherSuites = []uint16{
		tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
	}
	// default connection timeout
	DefaultConnectionTimeout = 5 * time.Second
	DefaultHomeDir           = "/var/rksync/production"
)

Configuration defaults

Functions

func ClientKeepaliveOptions

func ClientKeepaliveOptions(ka *KeepaliveConfig) []grpc.DialOption

ClientKeepaliveOptions returns gRPC keepalive options for clients.

func ServerKeepaliveOptions

func ServerKeepaliveOptions(ka *KeepaliveConfig) []grpc.ServerOption

ServerKeepaliveOptions returns gRPC keepalive options for server.

Types

type Config

type Config struct {
	HomeDir  string // The service's home directory
	Gossip   *GossipConfig
	Identity *IdentityConfig
	Server   *ServerConfig
}

Config defines the parameters for rksync

type File

type File interface {
	io.Closer
	io.ReaderAt
	io.Writer
}

File represents a file in the filesystem

type FileMeta added in v1.0.1

type FileMeta struct {
	Name     string
	Metadata []byte
	Leader   bool
}

FileMeta contains file metadata

type FileSystem

type FileSystem interface {
	// Create creates the named file
	Create(chainID string, fmeta FileMeta) (File, error)

	// OpenFile opens a file using the given flags and the given mode.
	OpenFile(chainID string, fmeta FileMeta, flag int, perm os.FileMode) (File, error)

	// Stat returns a FileInfo describing the named file.
	Stat(chainID string, fmeta FileMeta) (os.FileInfo, error)
}

FileSystem enables the rksync to communicate with file system.

type GossipConfig

type GossipConfig struct {
	FileSystem                 FileSystem    // File system
	BootstrapPeers             []string      // Peers we connect to at startup
	PropagateIterations        int           // Number of times a message is pushed to remote peer
	PropagatePeerNum           int           // Number of peers selected to push message to
	Endpoint                   string        // Peer endpoint
	MaxPropagationBurstSize    int           // Max number of messages stored until it triggers a push to remote peers
	MaxPropagationBurstLatency time.Duration // Max time between consecutive message pushes
	PullInterval               time.Duration // Determines frequency of pull phases
	PullPeerNum                int           // Number of peers to pull from
	PublishCertPeriod          time.Duration // Time from startup certifiates are included in Alive messages
	PublishStateInfoInterval   time.Duration // Determines frequency of pushing state info messages to peers
	RequestStateInfoInterval   time.Duration // Determines frequency of pulling state info message from peers
}

GossipConfig is the configuration of the rksync component

type IdentityConfig

type IdentityConfig struct {
	ID string // ID of this instance
	// contains filtered or unexported fields
}

IdentityConfig defines the identity parameters for peer

func (*IdentityConfig) GetCertificate

func (c *IdentityConfig) GetCertificate() []byte

GetCertificate returns the certificate file associated with the configuration

func (*IdentityConfig) GetIntermediateCAs

func (c *IdentityConfig) GetIntermediateCAs() [][]byte

GetIntermediateCAs returns the intermediate ca certificates associated with the configuration

func (*IdentityConfig) GetKeyStoreDir

func (c *IdentityConfig) GetKeyStoreDir() string

GetKeyStoreDir returns the key store directory

func (*IdentityConfig) GetRootCAs

func (c *IdentityConfig) GetRootCAs() [][]byte

GetRootCAs returns the root ca certificates associated with the configuration

func (*IdentityConfig) MakeFilesAbs

func (c *IdentityConfig) MakeFilesAbs(homedir string) error

MakeFilesAbs makes files absolute relative to 'HomeDir' if not already absolute

type KeepaliveConfig

type KeepaliveConfig struct {
	// ClientInterval is the duration after which if the client does not see
	// any activity from the server it pings the server to see if it is alive
	ClientInterval time.Duration
	// ClientTimeout is the duration the client waits for a response
	// from the server after sending a ping before closing the connection
	ClientTimeout time.Duration
	// ServerInterval is the duration after which if the server does not see
	// any activity from the client it pings the client to see if it is alive
	ServerInterval time.Duration
	// ServerTimeout is the duration the server waits for a response
	// from the client after sending a ping before closing the connection
	ServerTimeout time.Duration
	// ServerMinInterval is the minimum permitted time between client pings.
	// If clients send pings more frequently, the server will disconnect them
	ServerMinInterval time.Duration
}

KeepaliveConfig is used to set the gRPC keepalive settings for both clients and servers

type ServerConfig

type ServerConfig struct {
	ConnectionTimeout time.Duration
	SecOpts           *TLSConfig
	KaOpts            *KeepaliveConfig
}

ServerConfig defines the parameters for configuring a GRPCServer instance

type TLSConfig

type TLSConfig struct {
	Certificate       string
	Key               string
	ServerRootCAs     []string
	ClientRootCAs     []string
	UseTLS            bool
	RequireClientCert bool
	CipherSuites      []uint16
}

TLSConfig defines the TLS parameters for a gRPC server or gRPC client instance

Jump to

Keyboard shortcuts

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