vevt

package
v0.0.0-...-3b984fc Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogEvent

func LogEvent(
	op string,
	userID string,
	userName string,
	success bool,
	err string,
	data interface{})

LogEvent - logs an event using the registered audit function

func SetEventAuditor

func SetEventAuditor(auditor EventAuditor)

SetEventAuditor - sets the event auditor

Types

type Event

type Event struct {
	Op       string      `json:"op" bson:"op"`
	UserID   string      `json:"userID" bson:"userID"`
	UserName string      `json:"userName" bson:"userName"`
	Success  bool        `json:"success" bson:"success"`
	Error    string      `json:"error" bson:"error"`
	Time     time.Time   `json:"time" bson:"time"`
	Data     interface{} `json:"data" bson:"data"`
}

Event - represents a event initiated by a user while performing an operation

type EventAuditor

type EventAuditor interface {
	//LogEvent - logs given event into storage
	LogEvent(event *Event)

	//GetEvents - retrieves event entries based on filters
	GetEvents(offset, limit int,
		filter *vcmn.Filter) (
		total int,
		events []*Event,
		err error)

	//CreateIndices - creates mongoDB indeces for tables used for event logs
	CreateIndices() (err error)

	//CleanData - cleans event related data from database
	CleanData() (err error)
}

EventAuditor - handles application events for audit purposes

func GetAuditor

func GetAuditor() EventAuditor

GetAuditor - gets the event auditor

type MongoAuditor

type MongoAuditor struct{}

MongoAuditor - handles application events and stores them in mongodb for audit purposes

func (*MongoAuditor) CleanData

func (m *MongoAuditor) CleanData() (err error)

CleanData - cleans event related data from database

func (*MongoAuditor) CreateIndices

func (m *MongoAuditor) CreateIndices() (err error)

CreateIndices - creates mongoDB indeces for tables used for event logs

func (*MongoAuditor) GetEvents

func (m *MongoAuditor) GetEvents(offset, limit int, filter *vcmn.Filter) (
	total int, events []*Event, err error)

GetEvents - retrieves event entries based on filters

func (*MongoAuditor) LogEvent

func (m *MongoAuditor) LogEvent(event *Event)

LogEvent - stores event logs into database

type NoOpAuditor

type NoOpAuditor struct{}

NoOpAuditor - doesnt do anything, it's a dummy auditor

func (*NoOpAuditor) CleanData

func (n *NoOpAuditor) CleanData() (err error)

CleanData - there's nothing to clean

func (*NoOpAuditor) CreateIndices

func (n *NoOpAuditor) CreateIndices() (err error)

CreateIndices - creates nothing

func (*NoOpAuditor) GetEvents

func (n *NoOpAuditor) GetEvents(
	offset, limit int, filter *vcmn.Filter) (
	total int, events []*Event, err error)

GetEvents - gives an empty list of events

func (*NoOpAuditor) LogEvent

func (n *NoOpAuditor) LogEvent(event *Event)

LogEvent - logs event to console

type PGAuditor

type PGAuditor struct{}

PGAuditor - handles application events and stores them in postgres for audit purposes

func (*PGAuditor) CleanData

func (m *PGAuditor) CleanData() (err error)

CleanData - cleans event related data from database

func (*PGAuditor) CreateIndices

func (m *PGAuditor) CreateIndices() (err error)

CreateIndices - creates mongoDB indeces for tables used for event logs

func (*PGAuditor) GetEvents

func (m *PGAuditor) GetEvents(offset, limit int, filter *vcmn.Filter) (
	total int, events []*Event, err error)

GetEvents - retrieves event entries based on filters

func (*PGAuditor) LogEvent

func (m *PGAuditor) LogEvent(event *Event)

LogEvent - stores event logs into database

Jump to

Keyboard shortcuts

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