Documentation ¶
Index ¶
- Constants
- Variables
- func CloseConnections()
- func Connect(connConfig Config, suppressRegister bool, ...) bool
- func Disconnect() bool
- func EmitErrorEvent(jobName string, funcName string, err error)
- func EmitErrorEventKv(jobName string, funcName string, err error, kv map[string]string)
- func ForceConnected(t *testing.T)
- func FuncClientSingleton(funcName string, request interface{}) (result interface{}, err error)
- func GroupLogin() bool
- func IsEmergencyMode() bool
- func LoadCount() int
- func Login() bool
- func Reset()
- func ResetEmergencyMode()
- func SetEmergencyMode(t *testing.T, value bool)
- type AnalyticsRecord
- type Config
- type GeoData
- type Purger
- type SyncronizerForcer
Constants ¶
const ( ClientSingletonCall = "gorpcClientCall" FuncClientSingletonCall = "gorpcDispatcherClientCall" )
const ANALYTICS_KEYNAME = "tyk-system-analytics"
Variables ¶
var ( GlobalRPCCallTimeout = 30 * time.Second GlobalRPCPingTimeout = 60 * time.Second Log = &logrus.Logger{} Instrument *health.Stream // UseSyncLoginRPC for tests where we dont need to execute as a goroutine UseSyncLoginRPC bool AnalyticsSerializers []serializer.AnalyticsSerializer )
var ErrRPCIsDown = errors.New("RPCStorageHandler: rpc is either down or was not configured")
ErrRPCIsDown this is returned when we can't reach rpc server.
Functions ¶
func CloseConnections ¶
func CloseConnections()
func Connect ¶
func Connect(connConfig Config, suppressRegister bool, dispatcherFuncs map[string]interface{}, getGroupLoginFunc func(string, string) interface{}, emergencyModeFunc func(), emergencyModeLoadedFunc func()) bool
Connect will establish a connection to the RPC server specified in connection options
func Disconnect ¶
func Disconnect() bool
func EmitErrorEvent ¶
func EmitErrorEventKv ¶
func ForceConnected ¶
ForceConnected only intended to be used in tests do not use it for any other thing
func FuncClientSingleton ¶
FuncClientSingleton performs RPC call. This might be called before we have established RPC connection, in that case we perform a retry with exponential backoff ensuring indeed we can't connect to the rpc, this will eventually fall into emergency mode( That is handled outside of this function call)
func GroupLogin ¶
func GroupLogin() bool
func IsEmergencyMode ¶
func IsEmergencyMode() bool
func Login ¶
func Login() bool
Login tries to login to the rpc sever. Returns true if it succeeds and false if it fails.
func ResetEmergencyMode ¶
func ResetEmergencyMode()
func SetEmergencyMode ¶
SetEmergencyMode used in tests to force emergency mode
Types ¶
type AnalyticsRecord ¶
type AnalyticsRecord struct { Method string Path string RawPath string ContentLength int64 UserAgent string Day int Month time.Month Year int Hour int ResponseCode int APIKey string TimeStamp time.Time APIVersion string APIName string APIID string OrgID string OauthID string RequestTime int64 RawRequest string RawResponse string IPAddress string Geo GeoData Tags []string Alias string TrackPath bool ExpireAt time.Time `bson:"expireAt" json:"expireAt"` }
type Config ¶
type Config struct { UseSSL bool `json:"use_ssl"` SSLInsecureSkipVerify bool `json:"ssl_insecure_skip_verify"` SSLMinVersion uint16 `json:"ssl_min_version"` SSLMaxVersion uint16 `json:"ssl_max_version"` ConnectionString string `json:"connection_string"` RPCKey string `json:"rpc_key"` APIKey string `json:"api_key"` GroupID string `json:"group_id"` CallTimeout int `json:"call_timeout"` PingTimeout int `json:"ping_timeout"` RPCPoolSize int `json:"rpc_pool_size"` }
type GeoData ¶
type GeoData struct { Country struct { ISOCode string `maxminddb:"iso_code"` } `maxminddb:"country"` City struct { GeoNameID uint `maxminddb:"geoname_id"` Names map[string]string `maxminddb:"names"` } `maxminddb:"city"` Location struct { Latitude float64 `maxminddb:"latitude"` Longitude float64 `maxminddb:"longitude"` TimeZone string `maxminddb:"time_zone"` } `maxminddb:"location"` }
type Purger ¶
RPCPurger will purge analytics data into a Mongo database, requires that the Mongo DB string is specified in the Config object
func (*Purger) PurgeCache ¶
func (r *Purger) PurgeCache()
PurgeCache will pull the data from the in-memory store and drop it into the specified MongoDB collection
type SyncronizerForcer ¶
type SyncronizerForcer struct {
// contains filtered or unexported fields
}
func NewSyncForcer ¶
func NewSyncForcer(redisController *storage.RedisController) *SyncronizerForcer
NewSyncForcer returns a new syncforcer with a connected redis with a key prefix synchronizer-group- for group synchronization control.
func (*SyncronizerForcer) GroupLoginCallback ¶
func (sf *SyncronizerForcer) GroupLoginCallback(userKey string, groupID string) interface{}
GroupLoginCallback checks if the groupID key exists in the storage to turn on/off ForceSync param. If the the key doesn't exists in the storage, it creates it and set ForceSync to true