server

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTLSConfig

func GetTLSConfig(tlsConfig *TLSConfig, logger *log.Logger) (TLSConfig *tls.Config, err error)

func NewGRPCServer

func NewGRPCServer(opts ...grpcServerOption) (*grpcServer, error)

func NewKeypairReloader

func NewKeypairReloader(certPath, keyPath string, logger *log.Logger) (*keypairReloader, error)

func NewPostgresHandler added in v2.2.0

func NewPostgresHandler(api *pilosa.API, logger logger.Logger) pg.QueryHandler

NewPostgresHandler creates a postgres query handler wrapping the pilosa API.

func OptGRPCServerAPI

func OptGRPCServerAPI(api *pilosa.API) grpcServerOption

func OptGRPCServerListener

func OptGRPCServerListener(ln net.Listener) grpcServerOption

func OptGRPCServerLogger

func OptGRPCServerLogger(logger logger.Logger) grpcServerOption

func OptGRPCServerStats

func OptGRPCServerStats(stats stats.StatsClient) grpcServerOption

func OptGRPCServerTLSConfig added in v2.3.0

func OptGRPCServerTLSConfig(tlsConfig *tls.Config) grpcServerOption

func ToRowserWrapper

func ToRowserWrapper(result interface{}) (pb.ToRowser, error)

Normally we wouldn't need this wrapper, but since pilosa returns some concrete types for which we can't implement the ToRowser interface, we have to check for those here and then wrap them with a custom type.

func ToTablerWrapper

func ToTablerWrapper(result interface{}) (pb.ToTabler, error)

Normally we wouldn't need this wrapper, but since pilosa returns some concrete types for which we can't implement the ToTabler interface, we have to check for those here and then wrap them with a custom type.

Types

type Command

type Command struct {
	Server *pilosa.Server

	// Configuration.
	Config *Config

	// Standard input/output
	*pilosa.CmdIO

	// Started will be closed once Command.Start is finished.
	Started chan struct{}

	Handler pilosa.Handler

	API *pilosa.API
	// contains filtered or unexported fields
}

Command represents the state of the pilosa server command.

func NewCommand

func NewCommand(stdin io.Reader, stdout, stderr io.Writer, opts ...CommandOption) *Command

NewCommand returns a new instance of Main.

func (*Command) Close

func (m *Command) Close() error

Close shuts down the server.

func (*Command) GossipTransport

func (m *Command) GossipTransport() *gossip.Transport

GossipTransport allows a caller to return the gossip transport created when setting up the GossipMemberSet. This is useful if one needs to determine the allocated ephemeral port programmatically. (usually used in tests)

func (*Command) SetupServer

func (m *Command) SetupServer() error

SetupServer uses the cluster configuration to set up this server.

func (*Command) Start

func (m *Command) Start() (err error)

Start starts the pilosa server - it returns once the server is running.

func (*Command) UpAndDown

func (m *Command) UpAndDown() (err error)

func (*Command) Wait

func (m *Command) Wait() error

Wait waits for the server to be closed or interrupted.

type CommandOption

type CommandOption func(c *Command) error

func OptCommandCloseTimeout

func OptCommandCloseTimeout(d time.Duration) CommandOption

func OptCommandConfig

func OptCommandConfig(config *Config) CommandOption

func OptCommandServerOptions

func OptCommandServerOptions(opts ...pilosa.ServerOption) CommandOption

type Config

type Config struct {
	// DataDir is the directory where Pilosa stores both indexed data and
	// running state such as cluster topology information.
	DataDir string `toml:"data-dir"`

	// Bind is the host:port on which Pilosa will listen.
	Bind string `toml:"bind"`

	// BindGRPC is the host:port on which Pilosa will bind for gRPC.
	BindGRPC string `toml:"bind-grpc"`

	// Advertise is the address advertised by the server to other nodes
	// in the cluster. It should be reachable by all other nodes and should
	// route to an interface that Bind is listening on.
	Advertise string `toml:"advertise"`

	// AdvertiseGRPC is the address advertised by the server to other nodes
	// in the cluster. It should be reachable by all other nodes and should
	// route to an interface that BindGRPC is listening on.
	AdvertiseGRPC string `toml:"advertise-grpc"`

	// MaxWritesPerRequest limits the number of mutating commands that can be in
	// a single request to the server. This includes Set, Clear,
	// SetRowAttrs & SetColumnAttrs.
	MaxWritesPerRequest int `toml:"max-writes-per-request"`

	// LogPath configures where Pilosa will write logs.
	LogPath string `toml:"log-path"`

	// Verbose toggles verbose logging which can be useful for debugging.
	Verbose bool `toml:"verbose"`

	// HTTP Handler options
	Handler struct {
		// CORS Allowed Origins
		AllowedOrigins []string `toml:"allowed-origins"`
	} `toml:"handler"`

	// MaxMapCount puts an in-process limit on the number of mmaps. After this
	// is exhausted, Pilosa will fall back to reading the file into memory
	// normally.
	MaxMapCount uint64 `toml:"max-map-count"`

	// MaxFileCount puts a soft, in-process limit on the number of open fragment
	// files. Once this limit is passed, Pilosa will only keep files open while
	// actively working with them, and will close them afterward. This has a
	// negative effect on performance for workloads which make small appends to
	// lots of fragments.
	MaxFileCount uint64 `toml:"max-file-count"`

	// TLS
	TLS TLSConfig `toml:"tls"`

	// WorkerPoolSize controls how many goroutines are created for
	// processing queries. Defaults to runtime.NumCPU(). It is
	// intentionally not defined as a flag... only exposed here so
	// that we can limit the size while running tests in CI so we
	// don't exhaust the goroutine limit.
	WorkerPoolSize int `toml:"-"`

	// ImportWorkerPoolSize controls how many goroutines are created for
	// processing importRoaring jobs. Defaults to runtime.NumCPU(). It is
	// intentionally not defined as a flag... only exposed here so
	// that we can limit the size while running tests in CI so we
	// don't exhaust the goroutine limit.
	ImportWorkerPoolSize int `toml:"-"`

	Cluster struct {
		// Disabled controls whether clustering functionality is enabled.
		Disabled    bool     `toml:"disabled"`
		Coordinator bool     `toml:"coordinator"`
		ReplicaN    int      `toml:"replicas"`
		Hosts       []string `toml:"hosts"`
		Name        string   `toml:"name"`
		// This LongQueryTime is deprecated but still exists for backward compatibility
		LongQueryTime toml.Duration `toml:"long-query-time"`
	} `toml:"cluster"`

	LongQueryTime toml.Duration `toml:"long-query-time"`
	// Gossip config is based around memberlist.Config.
	Gossip gossip.Config `toml:"gossip"`

	Translation struct {
		MapSize int `toml:"map-size"`
		// DEPRECATED: Translation config supports translation store replication.
		PrimaryURL string `toml:"primary-url"`
	} `toml:"translation"`

	AntiEntropy struct {
		Interval toml.Duration `toml:"interval"`
	} `toml:"anti-entropy"`

	Metric struct {
		// Service can be statsd, prometheus, expvar, or none.
		Service string `toml:"service"`
		// Host tells the statsd client where to write.
		Host         string        `toml:"host"`
		PollInterval toml.Duration `toml:"poll-interval"`
		// Diagnostics toggles sending some limited diagnostic information to
		// Pilosa's developers.
		Diagnostics bool `toml:"diagnostics"`
	} `toml:"metric"`

	Tracing struct {
		// SamplerType is the type of sampler to use.
		SamplerType string `toml:"sampler-type"`
		// SamplerParam is the parameter passed to the tracing sampler.
		// Its meaning is dependent on the type of sampler.
		SamplerParam float64 `toml:"sampler-param"`
		// AgentHostPort is the host:port of the local agent.
		AgentHostPort string `toml:"agent-host-port"`
	} `toml:"tracing"`

	Profile struct {
		// BlockRate is passed directly to runtime.SetBlockProfileRate
		BlockRate int `toml:"block-rate"`
		// MutexFraction is passed directly to runtime.SetMutexProfileFraction
		MutexFraction int `toml:"mutex-fraction"`
	} `toml:"profile"`

	Postgres struct {
		// Bind is the address to which to bind a postgres endpoint.
		// If this is empty, no endpoint will be created.
		Bind string `toml:"bind"`
		// TLS configuration for postgres connections.
		TLS TLSConfig `toml:"tls"`

		StartupTimeout toml.Duration `toml:"startup-timeout"`
		ReadTimeout    toml.Duration `toml:"read-timeout"`
		WriteTimeout   toml.Duration `toml:"write-timout"`

		MaxStartupSize uint32 `toml:"max-startup-size"`

		// ConnectionLimit is the maximum number of postgres connections to allow simultaneously.
		// Setting this to 0 disables the limit.
		// This mostly exists because other DBs seem to have it.
		ConnectionLimit uint16 `toml:"max-connections"`
	} `toml:"postgres"`

	// Txsrc determines which Tx implementation the holder/Index will use; one
	// of the available transactional-storage engines. Choices are listed
	// in the string constants below. Should be one of
	// "roaring","bolt", "rbf", "bolt_roaring", "roaring_bolt", "rbf_roaring",
	// "roaring_rbf", "bolt_rbf", "rbf_bolt", or any later addition. The
	// engines with _ underscore indicate use of a blueGreenTx with a comparison
	// of values back from each Tx method, and a panic if they differ. This
	// is an effective test for consistency. If "rbf_roaring" is specified, then
	// the roaring values are the ones actually returned from the blueGreenTx.
	// If "roaring_rbf" is chosen, then the RBF values are the ones actually
	// returned from the blueGreenTx.
	Txsrc string `toml:"txsrc"`

	// RowcacheOn, if true, turns on the row cache for all storage backends.
	// The default is now off because it makes rbf queries faster and uses
	// much less memory.
	RowcacheOn bool `toml:"rowcache-on"`

	// RBFConfig defines all externally configurable RBF flags.
	RBFConfig *rbfcfg.Config

	// QueryHistoryLength sets the maximum number of queries that are maintained
	// for the /query-history endpoint. This parameter is per-node, and the
	// result combines the history from all nodes.
	QueryHistoryLength int
}

Config represents the configuration for the command.

func NewConfig

func NewConfig() *Config

NewConfig returns an instance of Config with default options.

func ParseConfig added in v2.3.0

func ParseConfig(s string) (Config, error)

ParseConfig parses s into a Config.

type GRPCHandler

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

GRPCHandler contains methods which handle the various gRPC requests.

func NewGRPCHandler

func NewGRPCHandler(api *pilosa.API) *GRPCHandler

func (*GRPCHandler) CreateIndex added in v2.8.0

CreateIndex creates a new Index

func (*GRPCHandler) DeleteIndex added in v2.8.0

DeleteIndex deletes an Index

func (*GRPCHandler) GetIndex added in v2.8.0

GetIndex returns a single Index given a name

func (*GRPCHandler) GetIndexes added in v2.8.0

GetIndexes returns a list of all Indexes

func (*GRPCHandler) Inspect

func (h *GRPCHandler) Inspect(req *pb.InspectRequest, stream pb.Pilosa_InspectServer) error

Inspect handles the inspect request and sends an InspectResponse to the stream.

func (*GRPCHandler) QueryPQL

func (h *GRPCHandler) QueryPQL(req *pb.QueryPQLRequest, stream pb.Pilosa_QueryPQLServer) error

QueryPQL handles the PQL request and sends RowResponses to the stream.

func (*GRPCHandler) QueryPQLUnary

func (h *GRPCHandler) QueryPQLUnary(ctx context.Context, req *pb.QueryPQLRequest) (*pb.TableResponse, error)

QueryPQLUnary is a unary-response (non-streaming) version of QueryPQL, returning a TableResponse.

Note comment above QuerySQLUnary describing the need for the *Unary methods.

func (*GRPCHandler) QuerySQL added in v2.2.0

func (h *GRPCHandler) QuerySQL(req *pb.QuerySQLRequest, stream pb.Pilosa_QuerySQLServer) error

QuerySQL handles the SQL request and sends RowResponses to the stream.

func (*GRPCHandler) QuerySQLUnary added in v2.2.0

func (h *GRPCHandler) QuerySQLUnary(ctx context.Context, req *pb.QuerySQLRequest) (*pb.TableResponse, error)

QuerySQLUnary is a unary-response (non-streaming) version of QuerySQL, returning a TableResponse.

Note regarding QuerySQLUnary and QueryPQLUnary: These methods are not ideal, as gRPC responses are payload-length limited to 4MB, so in most cases, we would recommend users use the QuerySQL and QueryPQL methods, as they stream the response as several small RowResponses. The response size limit is configurable on the client size, but we really only recommend these methods in the case that the payload is known to be quite small (e.g. single counts). These are provided mostly to support gRPC Futures, which are used by python-molecula to perform multiple queries concurrently. There is additional discussion and historical context here: https://github.com/molecula/pilosa/pull/644

func (*GRPCHandler) WithLogger

func (h *GRPCHandler) WithLogger(logger logger.Logger) *GRPCHandler

func (*GRPCHandler) WithStats

func (h *GRPCHandler) WithStats(stats stats.StatsClient) *GRPCHandler

type PostgresServer added in v2.2.0

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

PostgresServer provides a postgres endpoint on pilosa.

func NewPostgresServer added in v2.2.0

func NewPostgresServer(api *pilosa.API, logger logger.Logger, tls *tls.Config) *PostgresServer

NewPostgresServer creates a postgres server.

func (*PostgresServer) Close added in v2.2.0

func (s *PostgresServer) Close() error

func (*PostgresServer) Start added in v2.2.0

func (s *PostgresServer) Start(addr string) error

Start a postgres endpoint at the specified address.

type ResultBool

type ResultBool bool

ResultBool is a wrapper around a bool result type so that we can implement the ToTabler and ToRowser interfaces.

func (ResultBool) ToRows

func (r ResultBool) ToRows(callback func(*pb.RowResponse) error) error

ToRows implements the ToRowser interface.

func (ResultBool) ToTable

func (r ResultBool) ToTable() (*pb.TableResponse, error)

ToTable implements the ToTabler interface.

type ResultUint64

type ResultUint64 uint64

ResultUint64 is a wrapper around a uint64 result type so that we can implement the ToTabler and ToRowser interfaces.

func (ResultUint64) ToRows

func (r ResultUint64) ToRows(callback func(*pb.RowResponse) error) error

ToRows implements the ToRowser interface.

func (ResultUint64) ToTable

func (r ResultUint64) ToTable() (*pb.TableResponse, error)

ToTable implements the ToTabler interface.

type TLSConfig

type TLSConfig struct {
	// CertificatePath contains the path to the certificate (.crt or .pem file)
	CertificatePath string `toml:"certificate"`
	// CertificateKeyPath contains the path to the certificate key (.key file)
	CertificateKeyPath string `toml:"key"`
	// CACertPath is the path to a CA certificate (.crt or .pem file)
	CACertPath string `toml:"ca-certificate"`
	// SkipVerify disables verification of server certificates when connecting to another Pilosa node
	SkipVerify bool `toml:"skip-verify"`
	// EnableClientVerification enables verification of client TLS certificates (Mutual TLS)
	EnableClientVerification bool `toml:"enable-client-verification"`
}

TLSConfig contains TLS configuration

type VDSMGRPCHandler added in v2.3.0

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

VDSMGRPCHandler contains methods which handle the various gRPC requests, ported from VDSM.

func NewVDSMGRPCHandler added in v2.3.0

func NewVDSMGRPCHandler(grpcHandler *GRPCHandler, api *pilosa.API) *VDSMGRPCHandler

func (*VDSMGRPCHandler) DeleteVDS added in v2.3.0

DeleteVDS deletes a VDS

func (*VDSMGRPCHandler) GetVDS added in v2.3.0

GetVDSs returns a single VDS given a name

func (*VDSMGRPCHandler) GetVDSs added in v2.3.0

GetVDSs returns a list of all VDSs

func (*VDSMGRPCHandler) Inspect added in v2.3.0

func (*VDSMGRPCHandler) PostVDS added in v2.3.0

PostVDS creates a new VDS

func (*VDSMGRPCHandler) QueryPQL added in v2.3.0

func (*VDSMGRPCHandler) QueryPQLUnary added in v2.3.0

func (h *VDSMGRPCHandler) QueryPQLUnary(ctx context.Context, req *vdsm_pb.QueryPQLRequest) (*pb.TableResponse, error)

func (*VDSMGRPCHandler) QuerySQL added in v2.3.0

func (*VDSMGRPCHandler) QuerySQLUnary added in v2.3.0

func (h *VDSMGRPCHandler) QuerySQLUnary(ctx context.Context, req *pb.QuerySQLRequest) (*pb.TableResponse, error)

func (*VDSMGRPCHandler) WithLogger added in v2.3.0

func (h *VDSMGRPCHandler) WithLogger(logger logger.Logger) *VDSMGRPCHandler

func (*VDSMGRPCHandler) WithStats added in v2.3.0

func (h *VDSMGRPCHandler) WithStats(stats stats.StatsClient) *VDSMGRPCHandler

Jump to

Keyboard shortcuts

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