Documentation ¶
Index ¶
- Constants
- Variables
- func GetConnection(addr string, opts ...ConnOption) (*grpc.ClientConn, error)
- func GetLogger() log.Logger
- func SetLogger(lgr log.Logger)
- type ConnOption
- type GrpcServer
- type RandSessionKeyGen
- type RedisClient
- type RedisSessStorer
- type RegManager
- type Service
- type SessManager
- type SessStorer
Constants ¶
const MIN_SESSION_KEY_BYTE_LEN = 24
MIN_SESSION_KEY_BYTE_LEN represents the minimal allowed length of the session key in bytes, for security reasons.
Variables ¶
var DEFAULT_TIMEOUT_MILLIS = 5000
Functions ¶
func GetConnection ¶
func GetConnection(addr string, opts ...ConnOption) (*grpc.ClientConn, error)
GetConnection accepts address addr where a gRPC server is listening, and ConnOptions to configure the connection. It returns a connection that a client can use to contact the server or error in case of misconfiguration. // FIXME
Note that several clients can be passed the same connection, as the gRPC framework is able to multiplex several RPCs on the same connection, thus reducing the overhead.
Types ¶
type ConnOption ¶
type ConnOption func(*connOptions)
ConnOption is used to configure a connection to the server.
func WithCACert ¶
func WithCACert(caCert []byte) ConnOption
WithCACert sets the CA certificate for validating the server and returns the ConnOption.
func WithServerNameOverride ¶
func WithServerNameOverride(override string) ConnOption
WithServerNameOverride sets the string that will be compared to the CN field from server's cert during validation, and returns the ConnOption. This allows validation to pass even if server's hostname differs from certificate's CN.
func WithTimeout ¶
func WithTimeout(millis int) ConnOption
WithTimeout sets a timeout in milliseconds for establishing initial connection with the server.
type GrpcServer ¶
func NewGrpcServer ¶
func NewGrpcServer(certFile, keyFile string, logger log.Logger) (*GrpcServer, error)
NewGrpcServer initializes an instance of the GrpcServer struct and returns a pointer. It performs some default configuration (tracing of gRPC communication and interceptors) and registers RPC server handlers with gRPC server. It requires TLS cert and keyfile in order to establish a secure channel with clients.
func (*GrpcServer) EnableTracing ¶
func (s *GrpcServer) EnableTracing()
EnableTracing instructs the gRPC framework to enable its tracing capability, which is mainly used for debugging purposes. Although this function does not explicitly affect the GrpcServer struct, it is wired to GrpcServer in order to provide a nicer API when setting up the server.
func (*GrpcServer) RegisterService ¶
func (s *GrpcServer) RegisterService(r Service) error
RegisterService registers a Service service to the underlying gRPC server. It returns an error if a service is already registered.
func (*GrpcServer) Start ¶
func (s *GrpcServer) Start(port int) error
Start configures and starts the protocol server at the requested port.
func (*GrpcServer) Teardown ¶
func (s *GrpcServer) Teardown()
Teardown stops the protocol server by gracefully stopping enclosed gRPC server.
type RandSessionKeyGen ¶
type RandSessionKeyGen struct {
// contains filtered or unexported fields
}
RandSessionKeyGen generates session keys of the desired byte length from random bytes.
func NewRandSessionKeyGen ¶
func NewRandSessionKeyGen(byteLen int) (*RandSessionKeyGen, error)
NewRandSessionKeyGen creates a new RandSessionKeyGen instance. The new instance will be configured to generate session keys with exactly byteLen bytes. For security reasons, the function checks the byteLen against the value of MIN_SESSION_KEY_BYTE_LEN. If the provided byteLen is smaller than MIN_SESSION_KEY_BYTE_LEN, an error is set and the returned RandSessionKeyGen is configured to use MIN_SESSION_KEY_BYTE_LEN instead of the provided byteLen.
func (*RandSessionKeyGen) GenerateSessionKey ¶
func (m *RandSessionKeyGen) GenerateSessionKey() (*string, error)
GenerateSessionKey produces a secure random session key and returns its base64-encoded representation that is URL-safe. It reports an error in case random byte sequence could not be generated.
type RedisClient ¶
func NewRedisClient ¶
func NewRedisClient(c *redis.Client) *RedisClient
func (*RedisClient) CheckRegistrationKey ¶
func (c *RedisClient) CheckRegistrationKey(key string) (bool, error)
CheckRegistrationKey checks whether provided key is present in registration database and deletes it, preventing another registration with the same key. Returns true if key was present (registration allowed), false otherwise.
type RedisSessStorer ¶
func NewRedisSessStorer ¶
func NewRedisSessStorer(c *redis.Client) *RedisSessStorer
func (*RedisSessStorer) Store ¶
func (s *RedisSessStorer) Store(key string) error
type RegManager ¶
SessManager checks for the presence of a registration key, removing it in case it exists. The bolean return argument indicates success (registration key present and subsequently deleted) or failure (absence of registration key).
type SessManager ¶
SessManager generates a new session key. It returns a string containing the generated session key or an error in case session key could not be generated.
type SessStorer ¶
SessStorer stores arbitrary data associated with the authenticated session to the storage backend, returning error in case the data could not be stored.
Directories ¶
Path | Synopsis |
---|---|
clpb
Package clpb is a generated protocol buffer package.
|
Package clpb is a generated protocol buffer package. |
Package compatibility implements wrapper types, constants and functions around github.com/emmyzkp/emmy/client, making relevant functionality compatible with go language binding tools.
|
Package compatibility implements wrapper types, constants and functions around github.com/emmyzkp/emmy/client, making relevant functionality compatible with go language binding tools. |
ecpsyspb
Package ecpsyspb is a generated protocol buffer package.
|
Package ecpsyspb is a generated protocol buffer package. |
psyspb
Package psyspb is a generated protocol buffer package.
|
Package psyspb is a generated protocol buffer package. |