Documentation
¶
Index ¶
- Constants
- Variables
- func BufferStrings(args ...string) string
- func DefaultRecovery(arg interface{}) (ret_err error)
- func ExternalIP() (string, error)
- func MyCaller() string
- func NewEmailSendTask(parms taskParams, sender *MailerDaemon) *emailTask
- func NewUUID() (string, error)
- func ParseJWTprivKeyFile(file_path string) (*rsa.PrivateKey, error)
- func ParseJWTpubKeyFile(file_path string) (*rsa.PublicKey, error)
- func RandStringBytes(n int) string
- type CDNHostInfo
- type CmdResult
- type Configurations
- func (c *Configurations) CreateClientPool(heartbeat_map map[string]func(*grpc.ClientConn) error, conn_per_ep int) error
- func (c *Configurations) GetClientConfig(svc_name string) *GrpcClientConfig
- func (c *Configurations) GetPooledConn(svc_name string) *grpc.ClientConn
- func (c *Configurations) PooledConnDone(svc_name string, conn *grpc.ClientConn)
- type ConnEndpointInfo
- type DumbDBConfig
- type EmailConf
- type EmailerConfig
- type FsConfig
- type GrpcClientConfig
- func (c *GrpcClientConfig) CreatePool(no_of_conn int, do_heartbeat func(*grpc.ClientConn) error) error
- func (c *GrpcClientConfig) GetClientOpts() ([]grpc.DialOption, error)
- func (c *GrpcClientConfig) GetPooledConn() *grpc.ClientConn
- func (c *GrpcClientConfig) GiveupPooledConn(conn *grpc.ClientConn)
- func (c *GrpcClientConfig) NewRPCConn() (*grpc.ClientConn, error)
- func (c *GrpcClientConfig) WithJWTToken(token string) *GrpcClientConfig
- type GrpcServerConfig
- func (c *GrpcServerConfig) DefaultAuthFunction(ctx context.Context) (context.Context, error)
- func (c *GrpcServerConfig) GetServerOpts() ([]grpc.ServerOption, error)
- func (c *GrpcServerConfig) Valid() bool
- func (c *GrpcServerConfig) WithAuthFunc(auth func(context.Context) (context.Context, error))
- func (c *GrpcServerConfig) WithRecvFunc(recv grpc_recovery.RecoveryHandlerFunc)
- type JwtCredentials
- type LockerConfig
- type LogUtil
- func (l *LogUtil) AddEmailAlert(emails []string)
- func (l *LogUtil) Error(e error, format string, args ...interface{}) error
- func (l *LogUtil) FuncEntry(format string, args ...interface{})
- func (l *LogUtil) FuncExit(format string, args ...interface{})
- func (l *LogUtil) Info(format string, args ...interface{})
- func (l *LogUtil) Panic(e error, format string, args ...interface{}) error
- type MailerDaemon
- type MailerDaemonType
- type PaymentProvider
- type PostgresDBConfig
- type ProxyConfig
- type RedisConfig
- type RpcClientPool
Constants ¶
View Source
const ( PKG_NAME = "RpcClientPool" VERSION = "1.1" )
View Source
const FATAL_ERROR = "Unrecoverable error."
View Source
const INVALID_REQ = "Invalid request."
View Source
const NOENT = "Did not find entry."
Generic Errors
View Source
const SERIALIZATION_ERROR = "Error while serializing/de-serializing messages."
Variables ¶
View Source
var ( ErrUnknown = func(msg string, args ...interface{}) error { return status.Errorf(codes.Unknown, msg, args...) } ErrInvalidArg = func(msg string, args ...interface{}) error { return status.Errorf(codes.InvalidArgument, msg, args...) } ErrNotFound = func(msg string, args ...interface{}) error { return status.Errorf(codes.NotFound, msg, args...) } ErrAlreadyExists = func(msg string, args ...interface{}) error { return status.Errorf(codes.AlreadyExists, msg, args...) } ErrResourceExhausted = func(msg string, args ...interface{}) error { return status.Errorf(codes.ResourceExhausted, msg, args...) } ErrPermissionDenied = func(msg string, args ...interface{}) error { return status.Errorf(codes.PermissionDenied, msg, args...) } ErrUnauthenticated = func(msg string, args ...interface{}) error { return status.Errorf(codes.Unauthenticated, msg, args...) } ErrInternal = func(msg string, args ...interface{}) error { return status.Errorf(codes.Internal, msg, args...) } ErrUnimplemented = func(msg string, args ...interface{}) error { return status.Errorf(codes.Unimplemented, msg, args...) } return status.Errorf(codes.Unavailable, msg, args...) } )
Not all of the above errors are implemented. Add them as and when required.
View Source
var (
ERR_FATAL error = errors.New("Fatal error.")
)
Functions ¶
func BufferStrings ¶
func DefaultRecovery ¶
func DefaultRecovery(arg interface{}) (ret_err error)
func ExternalIP ¶
func MyCaller ¶
func MyCaller() string
MyCaller returns the caller of the function that called it :)
func NewEmailSendTask ¶
func NewEmailSendTask(parms taskParams, sender *MailerDaemon) *emailTask
func ParseJWTprivKeyFile ¶
func ParseJWTprivKeyFile(file_path string) (*rsa.PrivateKey, error)
func RandStringBytes ¶
Types ¶
type CDNHostInfo ¶
type CmdResult ¶
func ExecCommand ¶
type Configurations ¶
type Configurations struct {
ServerConfig GrpcServerConfig `json:"server_config"`
ClientConfig []GrpcClientConfig `json:"client_config"`
PostgresDB PostgresDBConfig `json:"postgres_db"`
DumbDB DumbDBConfig `json:"dumb_db"`
Emailer EmailerConfig `json:"emailer"`
Locker LockerConfig `json:"locker_config"`
FileStoreConfig FsConfig `json:"fs_config"`
Proxy ProxyConfig `json:"proxy_config"`
CDNInfo CDNHostInfo `json:"cdn_config"`
Payments []PaymentProvider `json:"payment_providers"`
RedisDB RedisConfig `json:"redis_config"`
// contains filtered or unexported fields
}
func ReadConfFile ¶
func ReadConfFile(file_path string) (*Configurations, error)
func (*Configurations) CreateClientPool ¶
func (c *Configurations) CreateClientPool(heartbeat_map map[string]func(*grpc.ClientConn) error, conn_per_ep int) error
func (*Configurations) GetClientConfig ¶
func (c *Configurations) GetClientConfig(svc_name string) *GrpcClientConfig
func (*Configurations) GetPooledConn ¶
func (c *Configurations) GetPooledConn(svc_name string) *grpc.ClientConn
func (*Configurations) PooledConnDone ¶
func (c *Configurations) PooledConnDone(svc_name string, conn *grpc.ClientConn)
type ConnEndpointInfo ¶
type DumbDBConfig ¶
type EmailerConfig ¶
type GrpcClientConfig ¶
type GrpcClientConfig struct {
// Name of the service for which client config is.
SvcName string `json:"svc_name"`
// Use TLS for encryption
UseTls bool `json:"use_tls"`
CertFile string `json:"cert_file"`
UseJwt bool `json:"use_jwt"`
ServerHostOverride string `json:"server_host_override"`
ServerAddr string `json:"server_addr"`
// Non-json fields
JwtToken string
// contains filtered or unexported fields
}
func (*GrpcClientConfig) CreatePool ¶
func (c *GrpcClientConfig) CreatePool(no_of_conn int, do_heartbeat func(*grpc.ClientConn) error) error
Single client conn pool needs to be synchronized externally.
func (*GrpcClientConfig) GetClientOpts ¶
func (c *GrpcClientConfig) GetClientOpts() ([]grpc.DialOption, error)
func (*GrpcClientConfig) GetPooledConn ¶
func (c *GrpcClientConfig) GetPooledConn() *grpc.ClientConn
func (*GrpcClientConfig) GiveupPooledConn ¶
func (c *GrpcClientConfig) GiveupPooledConn(conn *grpc.ClientConn)
func (*GrpcClientConfig) NewRPCConn ¶
func (c *GrpcClientConfig) NewRPCConn() (*grpc.ClientConn, error)
func (*GrpcClientConfig) WithJWTToken ¶
func (c *GrpcClientConfig) WithJWTToken(token string) *GrpcClientConfig
type GrpcServerConfig ¶
type GrpcServerConfig struct {
// Use TLS for encryption
UseTls bool `json:"use_tls"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
// Use JWT based authentication
UseJwt bool `json:"use_jwt"`
PubKeyFile string `json:"pub_key"`
PrivKeyFile string `json:"priv_key"`
UseValidator bool `json:"use_validator"`
UseRecovery bool `json:"use_recovery"`
Port int32 `json:"port"`
LogLevel int32 `json:"log_level"`
// Non-json fields
PubKey *rsa.PublicKey
PrivKey *rsa.PrivateKey
// contains filtered or unexported fields
}
func (*GrpcServerConfig) DefaultAuthFunction ¶
func (*GrpcServerConfig) GetServerOpts ¶
func (c *GrpcServerConfig) GetServerOpts() ([]grpc.ServerOption, error)
func (*GrpcServerConfig) Valid ¶
func (c *GrpcServerConfig) Valid() bool
func (*GrpcServerConfig) WithAuthFunc ¶
func (*GrpcServerConfig) WithRecvFunc ¶
func (c *GrpcServerConfig) WithRecvFunc(recv grpc_recovery.RecoveryHandlerFunc)
type JwtCredentials ¶
type JwtCredentials struct {
credentials.PerRPCCredentials
// contains filtered or unexported fields
}
func NewJwtCredentials ¶
func NewJwtCredentials(tok string) *JwtCredentials
func (*JwtCredentials) GetRequestMetadata ¶
func (j *JwtCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)
GetRequestMetadata gets the current request metadata
func (*JwtCredentials) RequireTransportSecurity ¶
func (j *JwtCredentials) RequireTransportSecurity() bool
Jwt does not RequireTransportSecurity
type LockerConfig ¶
type LogUtil ¶
type LogUtil struct {
// contains filtered or unexported fields
}
func (*LogUtil) AddEmailAlert ¶
type MailerDaemon ¶
type MailerDaemon struct {
// contains filtered or unexported fields
}
func NewMailerDaemon ¶
func NewMailerDaemon(host, username, password string, port int) *MailerDaemon
func (*MailerDaemon) SendEmail ¶
func (s *MailerDaemon) SendEmail(to, subject, message string, args ...interface{})
type MailerDaemonType ¶
type MailerDaemonType interface {
SendEmail(to, subject, message string, args ...interface{})
}
type PaymentProvider ¶
type PostgresDBConfig ¶
type PostgresDBConfig struct {
Hostname string `json:"hostname"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
DBName string `json:"db_name"`
}
func (*PostgresDBConfig) CreatePQDB ¶
func (dbConf *PostgresDBConfig) CreatePQDB() (*sql.DB, error)
func (*PostgresDBConfig) RemovePQDB ¶
func (dbConf *PostgresDBConfig) RemovePQDB() error
type ProxyConfig ¶
func (*ProxyConfig) Valid ¶
func (c *ProxyConfig) Valid() bool
type RedisConfig ¶
type RpcClientPool ¶
type RpcClientPool struct {
// contains filtered or unexported fields
}
func NewRpcClientPool ¶
func NewRpcClientPool(do_heartbeat func(*grpc.ClientConn) error, endpoints []interface{}, conn_per_ep int, logr_op io.Writer) *RpcClientPool
func (*RpcClientPool) Get ¶
func (r *RpcClientPool) Get() *grpc.ClientConn
func (*RpcClientPool) Put ¶
func (r *RpcClientPool) Put(conn *grpc.ClientConn)
Click to show internal directories.
Click to hide internal directories.