Documentation ¶
Index ¶
- Constants
- Variables
- func BuildHTTPAPIConnectionWrapper(tlsWrapper *network.TLSConnectionWrapper, clientIDFromCert bool, ...) (network.HTTPServerConnectionWrapper, error)
- func NewMetricConnectionCallback(connectionType string) *network.MetricConnectionCallback
- func RegisterMetrics(serviceName string, version *utils.Version, edition utils.ProductEdition)
- type APICore
- type ClientSession
- func (clientSession *ClientSession) ClientConnection() net.Conn
- func (clientSession *ClientSession) Close()
- func (clientSession *ClientSession) ConnectToDb() error
- func (clientSession *ClientSession) Context() context.Context
- func (clientSession *ClientSession) DatabaseConnection() net.Conn
- func (clientSession *ClientSession) DeleteData(key string)
- func (clientSession *ClientSession) GetData(key string) (interface{}, bool)
- func (clientSession *ClientSession) HasData(key string) bool
- func (clientSession *ClientSession) Logger() *log.Entry
- func (clientSession *ClientSession) PreparedStatementRegistry() base.PreparedStatementRegistry
- func (clientSession *ClientSession) ProtocolState() interface{}
- func (clientSession *ClientSession) SetData(key string, data interface{})
- func (clientSession *ClientSession) SetPreparedStatementRegistry(registry base.PreparedStatementRegistry)
- func (clientSession *ClientSession) SetProtocolState(state interface{})
- type Config
- func (config *Config) DetectPoisonRecords() bool
- func (config *Config) GetAcraAPIConnectionString() string
- func (config *Config) GetAcraConnectionString() string
- func (config *Config) GetCensor() acracensor.AcraCensorInterface
- func (config *Config) GetConfigPath() string
- func (config *Config) GetDBHost() string
- func (config *Config) GetDBPort() int
- func (config *Config) GetDebug() bool
- func (config *Config) GetEnableHTTPAPI() bool
- func (config *Config) GetKeyStore() keystore.ServerKeyStore
- func (config *Config) GetSQLDialect() dialect.Dialect
- func (config *Config) GetServiceName() string
- func (config *Config) GetStaticClientID() []byte
- func (config *Config) GetTLSClientIDExtractor() network.TLSClientIDExtractor
- func (config *Config) GetTableSchema() encryptorConfig.TableSchemaStore
- func (config *Config) GetTraceOptions() []trace.StartOption
- func (config *Config) GetUseClientIDFromCertificate() bool
- func (config *Config) LoadMapTableSchemaConfig(extractor *args.ServiceExtractor, storageType string, useMySQL bool) error
- func (config *Config) SetAcraAPIConnectionString(str string)
- func (config *Config) SetAcraConnectionString(str string)
- func (config *Config) SetCensor(censorConfigPath string) error
- func (config *Config) SetConfigPath(path string)
- func (config *Config) SetDBConnectionSettings(host string, port int)
- func (config *Config) SetDatabaseType(mysql, postgresql bool) error
- func (config *Config) SetDebug(value bool)
- func (config *Config) SetDetectPoisonRecords(val bool)
- func (config *Config) SetEnableHTTPAPI(api bool)
- func (config *Config) SetKeyStore(k keystore.ServerKeyStore)
- func (config *Config) SetScriptOnPoison(script string)
- func (config *Config) SetServiceName(name string)
- func (config *Config) SetStaticClientID(clientID []byte) error
- func (config *Config) SetStopOnPoison(stop bool)
- func (config *Config) SetTLSClientIDExtractor(tlsClientIDExtractor network.TLSClientIDExtractor)
- func (config *Config) SetTableSchema(store encryptorConfig.TableSchemaStore)
- func (config *Config) SetUseClientIDFromCertificate(use bool)
- func (config *Config) UseMySQL() bool
- func (config *Config) UsePostgreSQL() bool
- type ConnectionContextCallback
- type HTTPAPIServer
- type SServer
- func (server *SServer) Close()
- func (server *SServer) ConnectionsCounter() int
- func (server *SServer) Exit(err error)
- func (server *SServer) ListenerAPI() net.Listener
- func (server *SServer) ListenerAcra() net.Listener
- func (server *SServer) Start(parentContext context.Context)
- func (server *SServer) StartCommands(parentContext context.Context)
- func (server *SServer) StartCommandsFromFileDescriptor(parentContext context.Context, fd uintptr)
- func (server *SServer) StartFromFileDescriptor(parentContext context.Context, fd uintptr)
- func (server *SServer) StartServer(parentContext context.Context, group *sync.WaitGroup, enableHTTPApi bool) error
- func (server *SServer) StartServerFromFileDescriptor(parentContext context.Context, group *sync.WaitGroup, enableHTTPApi bool, ...) error
- func (server *SServer) StopListeners()
- func (server *SServer) WaitConnections(duration time.Duration)
- func (server *SServer) WaitWithTimeout(duration time.Duration) error
Constants ¶
const TimeoutToExit = time.Second
TimeoutToExit timeout for exit operation for SServer component
Variables ¶
var ErrShutdownAttemptWithoutExit = errors.New("unexpected way to shutdown service")
ErrShutdownAttemptWithoutExit is an error occurred when context cancelled but Exit function is not called
var ErrTwoDBSetup = errors.New("only one db supported at one time")
ErrTwoDBSetup shows that AcraServer can connects only to one database at the same time
var ErrWaitTimeout = errors.New("timeout")
ErrWaitTimeout error indicates that server was shutdown and waited N seconds while shutting down all connections.
Functions ¶
func BuildHTTPAPIConnectionWrapper ¶
func BuildHTTPAPIConnectionWrapper(tlsWrapper *network.TLSConnectionWrapper, clientIDFromCert bool, clientID []byte) (network.HTTPServerConnectionWrapper, error)
BuildHTTPAPIConnectionWrapper builds the connection wrapper that will be used by the HTTP API server. If `tlsWrapper` is nil, no TLS protection is used and connections will use the specified clientID. If clientIDFromCert is true, the clientID will be derived from the TLS user certificate. If false, the static clientID will be used.
func NewMetricConnectionCallback ¶
func NewMetricConnectionCallback(connectionType string) *network.MetricConnectionCallback
NewMetricConnectionCallback return initialized MetricConnectionCallback with proper connectionType
func RegisterMetrics ¶
func RegisterMetrics(serviceName string, version *utils.Version, edition utils.ProductEdition)
RegisterMetrics registers AcraServer metrics.
Types ¶
type APICore ¶
type APICore struct {
// contains filtered or unexported fields
}
APICore contains the API logic of the HTTP API server Is used to decouple the API logic from actual HTTP setting routine In the future could be used to abstract HTTP setting up from API configuring
func NewAPICore ¶
func NewAPICore(ctx context.Context, keystore keystore.ServerKeyStore) APICore
NewAPICore creates new APICore
type ClientSession ¶
type ClientSession struct {
// contains filtered or unexported fields
}
ClientSession handles connection between database and AcraServer.
func NewClientSession ¶
func NewClientSession(ctx context.Context, config *Config, connection net.Conn) (*ClientSession, error)
NewClientSession creates new ClientSession object.
func (*ClientSession) ClientConnection ¶
func (clientSession *ClientSession) ClientConnection() net.Conn
ClientConnection returns connection to AcraConnector.
func (*ClientSession) Close ¶
func (clientSession *ClientSession) Close()
Close session connections to AcraConnector and database.
func (*ClientSession) ConnectToDb ¶
func (clientSession *ClientSession) ConnectToDb() error
ConnectToDb connects to the database via tcp using Host and Port from config.
func (*ClientSession) Context ¶
func (clientSession *ClientSession) Context() context.Context
Context returns session's context.
func (*ClientSession) DatabaseConnection ¶
func (clientSession *ClientSession) DatabaseConnection() net.Conn
DatabaseConnection returns connection to database. It must be established first by ConnectToDb().
func (*ClientSession) DeleteData ¶
func (clientSession *ClientSession) DeleteData(key string)
DeleteData delete session related data by key
func (*ClientSession) GetData ¶
func (clientSession *ClientSession) GetData(key string) (interface{}, bool)
GetData return session related data by key and true otherwise nil, false
func (*ClientSession) HasData ¶
func (clientSession *ClientSession) HasData(key string) bool
HasData return true if session has data by key
func (*ClientSession) Logger ¶
func (clientSession *ClientSession) Logger() *log.Entry
Logger returns session's logger.
func (*ClientSession) PreparedStatementRegistry ¶
func (clientSession *ClientSession) PreparedStatementRegistry() base.PreparedStatementRegistry
PreparedStatementRegistry returns prepared statement registry of this session. The session does not have a registry by default, it must be set with SetPreparedStatementRegistry.
func (*ClientSession) ProtocolState ¶
func (clientSession *ClientSession) ProtocolState() interface{}
ProtocolState returns private protocol state of this session. The session does not have any state by default, it must be set with SetProtocolState.
func (*ClientSession) SetData ¶
func (clientSession *ClientSession) SetData(key string, data interface{})
SetData save session related data by key
func (*ClientSession) SetPreparedStatementRegistry ¶
func (clientSession *ClientSession) SetPreparedStatementRegistry(registry base.PreparedStatementRegistry)
SetPreparedStatementRegistry sets prepared statement registry for this session.
func (*ClientSession) SetProtocolState ¶
func (clientSession *ClientSession) SetProtocolState(state interface{})
SetProtocolState sets protocol state for this session.
type Config ¶
type Config struct { ConnectionWrapper network.ConnectionWrapper HTTPAPIConnectionWrapper network.HTTPServerConnectionWrapper TraceToLog bool // contains filtered or unexported fields }
Config describes AcraServer configuration
func (*Config) DetectPoisonRecords ¶
DetectPoisonRecords returns if AcraServer should detect Poison records
func (*Config) GetAcraAPIConnectionString ¶
GetAcraAPIConnectionString returns AcraServer API connection string
func (*Config) GetAcraConnectionString ¶
GetAcraConnectionString returns AcraServer data connection string
func (*Config) GetCensor ¶
func (config *Config) GetCensor() acracensor.AcraCensorInterface
GetCensor returns AcraCensor associated with AcraServer
func (*Config) GetConfigPath ¶
GetConfigPath returns AcraServer config path
func (*Config) GetDebug ¶
GetDebug returns if AcraServer should run in debug mode and print debug logs
func (*Config) GetEnableHTTPAPI ¶
GetEnableHTTPAPI returns if AcraServer should listen to HTTP commands
func (*Config) GetKeyStore ¶
func (config *Config) GetKeyStore() keystore.ServerKeyStore
GetKeyStore return configure KeyStore
func (*Config) GetSQLDialect ¶
GetSQLDialect returns MySQL or PostgreSQL dialect depending on the configuration.
func (*Config) GetServiceName ¶
GetServiceName returns AcraServer service name.
func (*Config) GetStaticClientID ¶
GetStaticClientID returns configured static clientID
func (*Config) GetTLSClientIDExtractor ¶
func (config *Config) GetTLSClientIDExtractor() network.TLSClientIDExtractor
GetTLSClientIDExtractor return configured TLSClietIDExtractor
func (*Config) GetTableSchema ¶
func (config *Config) GetTableSchema() encryptorConfig.TableSchemaStore
GetTableSchema returns table schema in use.
func (*Config) GetTraceOptions ¶
func (config *Config) GetTraceOptions() []trace.StartOption
GetTraceOptions return configured trace StartOptions
func (*Config) GetUseClientIDFromCertificate ¶
GetUseClientIDFromCertificate return is acra-server should use clientID from the certificate
func (*Config) LoadMapTableSchemaConfig ¶
func (config *Config) LoadMapTableSchemaConfig(extractor *args.ServiceExtractor, storageType string, useMySQL bool) error
LoadMapTableSchemaConfig load table schemas from config file
func (*Config) SetAcraAPIConnectionString ¶
SetAcraAPIConnectionString sets AcraServer API connection string
func (*Config) SetAcraConnectionString ¶
SetAcraConnectionString sets AcraServer data connection string
func (*Config) SetConfigPath ¶
SetConfigPath sets AcraServer config path
func (*Config) SetDBConnectionSettings ¶
SetDBConnectionSettings sets address of the database.
func (*Config) SetDatabaseType ¶
SetDatabaseType set mysql or postgresql, return ErrTwoDBSetup if both true, set postgresql true if both false
func (*Config) SetDetectPoisonRecords ¶
SetDetectPoisonRecords sets if AcraServer should detect Poison records
func (*Config) SetEnableHTTPAPI ¶
SetEnableHTTPAPI sets if AcraServer should listen to HTTP commands
func (*Config) SetKeyStore ¶
func (config *Config) SetKeyStore(k keystore.ServerKeyStore)
SetKeyStore sets keystore.
func (*Config) SetScriptOnPoison ¶
SetScriptOnPoison sets path to script to execute when poison record is triggered.
func (*Config) SetServiceName ¶
SetServiceName sets AcraServer service name.
func (*Config) SetStaticClientID ¶
SetStaticClientID set clientID to use for all incoming connections with turned off through TLS certificate identification
func (*Config) SetStopOnPoison ¶
SetStopOnPoison tells AcraServer to shutdown when poison record is triggered.
func (*Config) SetTLSClientIDExtractor ¶
func (config *Config) SetTLSClientIDExtractor(tlsClientIDExtractor network.TLSClientIDExtractor)
SetTLSClientIDExtractor set clientID extractor from TLS metadata
func (*Config) SetTableSchema ¶
func (config *Config) SetTableSchema(store encryptorConfig.TableSchemaStore)
SetTableSchema set TableSchemaStore
func (*Config) SetUseClientIDFromCertificate ¶
SetUseClientIDFromCertificate set should acra-server use clientID from the certificate or not
func (*Config) UsePostgreSQL ¶
UsePostgreSQL returns if AcraServer should connect to PostgreSQL database
type ConnectionContextCallback ¶
ConnectionContextCallback is callback that is called to map context for each connection We use it to set the connection to the context, so it can be use latter (for extracting the clientID for example)
type HTTPAPIServer ¶
type HTTPAPIServer struct {
// contains filtered or unexported fields
}
HTTPAPIServer handles all HTTP api logic
func NewHTTPAPIServer ¶
func NewHTTPAPIServer( ctx context.Context, keystore keystore.ServerKeyStore, traceOn bool, traceOptions []trace.StartOption, tlsIDExtractor network.TLSClientIDExtractor, connCtxCallback ConnectionContextCallback, ) HTTPAPIServer
NewHTTPAPIServer creates new AcraAPIServer The arguments: - keystore is a keystore operated by the Acra - traceOn controls the tracing. Often provided from the config. - traceOptions - options for the tracer. Often provided from the config. - tlsIDExtractor is used to extract IDs from the TLS connection - connCtxCallback is a callback for setting context for each connection
func (*HTTPAPIServer) InitEngine ¶
func (apiServer *HTTPAPIServer) InitEngine(engine *gin.Engine)
InitEngine configures all path handlers for the API
type SServer ¶
type SServer struct {
// contains filtered or unexported fields
}
SServer represents AcraServer server, connects with KeyStorage, configuration file, data and command connections (listeners, managers, file descriptors), and signals.
func NewEEAcraServerMainComponent ¶
func NewEEAcraServerMainComponent(config *Config, proxyFactory base.ProxyFactory, errorChan chan os.Signal, restartChan chan os.Signal) (*SServer, error)
NewEEAcraServerMainComponent creates new SServer wrapper
func (*SServer) ConnectionsCounter ¶
ConnectionsCounter counts number of active data and API connections.
func (*SServer) Exit ¶
Exit exits SServer by sending the input error to the internal channel that is listened in Start function
func (*SServer) ListenerAPI ¶
ListenerAPI returns listener for AcraServer management API connections.
func (*SServer) ListenerAcra ¶
ListenerAcra returns listener for AcraServer database connections.
func (*SServer) StartCommands ¶
StartCommands starts listening commands connections from proxy.
func (*SServer) StartCommandsFromFileDescriptor ¶
StartCommandsFromFileDescriptor starts listening commands connections from file descriptor.
func (*SServer) StartFromFileDescriptor ¶
StartFromFileDescriptor starts listening Acra data connections from file descriptor.
func (*SServer) StartServer ¶
func (server *SServer) StartServer(parentContext context.Context, group *sync.WaitGroup, enableHTTPApi bool) error
StartServer starts SServer
func (*SServer) StartServerFromFileDescriptor ¶
func (server *SServer) StartServerFromFileDescriptor(parentContext context.Context, group *sync.WaitGroup, enableHTTPApi bool, fdAcra, fdAPI uintptr) error
StartServerFromFileDescriptor starts SServer with appropriate file descriptors
func (*SServer) StopListeners ¶
func (server *SServer) StopListeners()
StopListeners stops accepts new connections, and stops existing listeners with deadline.
func (*SServer) WaitConnections ¶
WaitConnections waits until connection complete or stops them after duration time.