rpc

package
v1.7.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MPL-2.0 Imports: 21 Imported by: 12

Documentation

Index

Constants

View Source
const (
	ClientSingletonCall     = "gorpcClientCall"
	FuncClientSingletonCall = "gorpcDispatcherClientCall"
)
View Source
const ANALYTICS_KEYNAME = "tyk-system-analytics"

Variables

View Source
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
)
View Source
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 EmitErrorEvent(jobName string, funcName string, err error)

func EmitErrorEventKv

func EmitErrorEventKv(jobName string, funcName string, err error, kv map[string]string)

func ForceConnected

func ForceConnected(t *testing.T)

ForceConnected only intended to be used in tests do not use it for any other thing

func FuncClientSingleton

func FuncClientSingleton(funcName string, request interface{}) (result interface{}, err error)

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 LoadCount

func LoadCount() int

func Login

func Login() bool

Login tries to login to the rpc sever. Returns true if it succeeds and false if it fails.

func Reset

func Reset()

func ResetEmergencyMode

func ResetEmergencyMode()

func SetEmergencyMode

func SetEmergencyMode(t *testing.T, value bool)

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

type Purger struct {
	Store storage.Handler
}

RPCPurger will purge analytics data into a Mongo database, requires that the Mongo DB string is specified in the Config object

func (*Purger) Connect

func (r *Purger) Connect()

Connect Connects to RPC

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

func (Purger) PurgeLoop

func (r Purger) PurgeLoop(ctx context.Context, interval time.Duration)

PurgeLoop starts the loop that will pull data out of the in-memory store and into RPC.

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

Jump to

Keyboard shortcuts

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