audit

package
v0.0.0-...-122f59b Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DependencySet = wire.NewSet(
	NewLogger,
	wire.Struct(new(Sink), "*"),
	wire.Struct(new(ReadStore), "*"),
	wire.Struct(new(WriteStore), "*"),
	wire.Struct(new(Query), "*"),
)

Functions

This section is empty.

Types

type Log

type Log struct {
	ID           string                 `json:"id"`
	CreatedAt    time.Time              `json:"createdAt"`
	ActivityType string                 `json:"activityType"`
	UserID       string                 `json:"userID,omitempty"`
	IPAddress    string                 `json:"ipAddress,omitempty"`
	UserAgent    string                 `json:"userAgent,omitempty"`
	ClientID     string                 `json:"clientID,omitempty"`
	Data         map[string]interface{} `json:"data,omitempty"`
}

Log represents an audit log entry. The keys in JSON struct tags are in camel case because this struct is directly returned in the GraphQL endpoint. Making the keys in camel case saves us from writing boilerplate resolver code.

func NewLog

func NewLog(e *event.Event) (*Log, error)

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type Query

type Query struct {
	Database *auditdb.ReadHandle
	Store    *ReadStore
}

func (*Query) Count

func (q *Query) Count(opts QueryPageOptions) (uint64, error)

func (*Query) GetByIDs

func (q *Query) GetByIDs(ids []string) ([]*Log, error)

func (*Query) QueryPage

func (q *Query) QueryPage(opts QueryPageOptions, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

type QueryPageOptions

type QueryPageOptions struct {
	RangeFrom     *time.Time
	RangeTo       *time.Time
	ActivityTypes []string
	UserIDs       []string
	SortDirection model.SortDirection
}

func (QueryPageOptions) Apply

type ReadStore

type ReadStore struct {
	SQLBuilder  *auditdb.SQLBuilderApp
	SQLExecutor *auditdb.ReadSQLExecutor
}

func (*ReadStore) Count

func (s *ReadStore) Count(opts QueryPageOptions) (uint64, error)

func (*ReadStore) GetByIDs

func (s *ReadStore) GetByIDs(ids []string) ([]*Log, error)

func (*ReadStore) QueryPage

func (s *ReadStore) QueryPage(opts QueryPageOptions, pageArgs graphqlutil.PageArgs) ([]*Log, uint64, error)

type Sink

type Sink struct {
	Logger   Logger
	Database *auditdb.WriteHandle
	Store    *WriteStore
}

func (*Sink) ReceiveBlockingEvent

func (s *Sink) ReceiveBlockingEvent(e *event.Event) (err error)

func (*Sink) ReceiveNonBlockingEvent

func (s *Sink) ReceiveNonBlockingEvent(e *event.Event) (err error)

type WriteStore

type WriteStore struct {
	SQLBuilder  *auditdb.SQLBuilderApp
	SQLExecutor *auditdb.WriteSQLExecutor
}

func (*WriteStore) PersistLog

func (s *WriteStore) PersistLog(logEntry *Log) (err error)

Jump to

Keyboard shortcuts

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