Documentation
¶
Overview ¶
Package analytics defines functions and structs used to store authorization audit data to redis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationToMillisecond ¶
DurationToMillisecond convert time duration type to floag64.
Types ¶
type Analytics ¶
type Analytics struct {
// contains filtered or unexported fields
}
Analytics will record analytics data to a redis back end as defined in the Config object.
func GetAnalytics ¶
func GetAnalytics() *Analytics
GetAnalytics returns the existed analytics instance. Need to initialize `analytics` instance before calling GetAnalytics.
func NewAnalytics ¶
func NewAnalytics(options *AnalyticsOptions, store storage.AnalyticsHandler) *Analytics
NewAnalytics returns a new analytics instance.
func (*Analytics) RecordHit ¶
func (r *Analytics) RecordHit(record *AnalyticsRecord) error
RecordHit will store an AnalyticsRecord in Redis.
type AnalyticsOptions ¶
type AnalyticsOptions struct {
PoolSize int `json:"pool-size" mapstructure:"pool-size"`
RecordsBufferSize uint64 `json:"records-buffer-size" mapstructure:"records-buffer-size"`
FlushInterval uint64 `json:"flush-interval" mapstructure:"flush-interval"`
StorageExpirationTime time.Duration `json:"storage-expiration-time" mapstructure:"storage-expiration-time"`
Enable bool `json:"enable" mapstructure:"enable"`
EnableDetailedRecording bool `json:"enable-detailed-recording" mapstructure:"enable-detailed-recording"`
}
AnalyticsOptions contains configuration items related to analytics.
func NewAnalyticsOptions ¶
func NewAnalyticsOptions() *AnalyticsOptions
NewAnalyticsOptions creates a AnalyticsOptions object with default parameters.
func (*AnalyticsOptions) AddFlags ¶
func (o *AnalyticsOptions) AddFlags(fs *pflag.FlagSet)
AddFlags adds flags related to features for a specific api server to the specified FlagSet.
func (*AnalyticsOptions) Validate ¶
func (o *AnalyticsOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type AnalyticsRecord ¶
type AnalyticsRecord struct {
TimeStamp int64 `json:"timestamp"`
Username string `json:"username"`
Effect string `json:"effect"`
Conclusion string `json:"conclusion"`
Request string `json:"request"`
Policies string `json:"policies"`
Deciders string `json:"deciders"`
ExpireAt time.Time `json:"expireAt" bson:"expireAt"`
}
AnalyticsRecord encodes the details of a authorization request.
func (*AnalyticsRecord) SetExpiry ¶
func (a *AnalyticsRecord) SetExpiry(expiresInSeconds int64)
SetExpiry set expiration time to a key.