analytics

package
v0.0.0-...-3266887 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 8 Imported by: 0

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

func DurationToMillisecond(d time.Duration) float64

DurationToMillisecond convert time duration type to float64.

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.

func (*Analytics) Start

func (r *Analytics) Start()

Start start the analytics service.

func (*Analytics) Stop

func (r *Analytics) Stop()

Stop stop the analytics service.

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.

Jump to

Keyboard shortcuts

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