app

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleDialTLSConfig

func SimpleDialTLSConfig(cert tls.Certificate, pool *x509.CertPool) *tls.Config

SimpleDialTLSConfig returns a client-side TLS configuration with sane defaults (e.g. TLS version, ciphers and mutual authentication).

The cert parameter must be a public/private key pair, typically loaded from disk using tls.LoadX509KeyPair().

The pool parameter can be used to specify a custom signing CA (e.g. for self-signed certificates).

When server and client both use the same certificate, the same key pair and pool should be passed to SimpleListenTLSConfig() in order to generate the server-side config.

The returned config can be used as "client" parameter for the WithTLS App option, or as "config" parameter for the client.DialFuncWithTLS() helper.

func SimpleListenTLSConfig

func SimpleListenTLSConfig(cert tls.Certificate, pool *x509.CertPool) *tls.Config

SimpleListenTLSConfig returns a server-side TLS configuration with sane defaults (e.g. TLS version, ciphers and mutual authentication).

The cert parameter must be a public/private key pair, typically loaded from disk using tls.LoadX509KeyPair().

The pool parameter can be used to specify a custom signing CA (e.g. for self-signed certificates).

When server and client both use the same certificate, the same key pair and pool should be passed to SimpleDialTLSConfig() in order to generate the client-side config.

The returned config can be used as "listen" parameter for the WithTLS option.

func SimpleTLSConfig

func SimpleTLSConfig(cert tls.Certificate, pool *x509.CertPool) (*tls.Config, *tls.Config)

Types

type App

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

func New

func New(dir string, options ...Option) (*App, error)

New creates a new application node.

func (*App) Close

func (a *App) Close() error

Close the application node, releasing all resources it created.

func (*App) ID

func (a *App) ID() uint64

ID returns the dqlite ID of this application node.

func (*App) Leader

func (a *App) Leader(ctx context.Context) (*client.Client, error)

Leader returns a client connected to the current cluster leader, if any.

func (*App) Open

func (a *App) Open(ctx context.Context, database string) (*sql.DB, error)

Open the dqlite database with the given name

type Option

type Option func(*options)

Option can be used to tweak app parameters.

func WithAddress

func WithAddress(address string) Option

WithAddress sets the network address of the application node.

Other application nodes must be able to connect to this application node using the given address.

If the application node is not the first one in the cluster, the address must match the value that was passed to the App.Add() method upon registration.

If not given the first non-loopback IP address of any of the system network interfaces will be used, with port 9000.

The address must be stable across application restarts.

func WithCluster

func WithCluster(cluster []string) Option

WithCluster must be used when starting a newly added application node for the first time.

It should contain the addresses of one or more applications nodes which are already part of the cluster.

func WithLogFunc

func WithLogFunc(log client.LogFunc) Option

WithLogFunc sets a custom log function.

func WithTLS

func WithTLS(listen *tls.Config, dial *tls.Config) Option

WithTLS enables TLS encryption of network traffic.

The "listen" parameter must hold the TLS configuration to use when accepting incoming connections clients or application nodes.

The "dial" parameter must hold the TLS configuration to use when establishing outgoing connections to other application nodes.

Jump to

Keyboard shortcuts

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