audit

package
v0.0.0-...-ee57881 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

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(ctx context.Context, opts QueryPageOptions) (uint64, error)

func (*Query) GetByIDs

func (q *Query) GetByIDs(ctx context.Context, ids []string) ([]*Log, error)

func (*Query) QueryPage

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

type QueryPageOptions

type QueryPageOptions struct {
	RangeFrom      *time.Time
	RangeTo        *time.Time
	ActivityTypes  []string
	UserIDs        []string
	EmailAddresses []string
	PhoneNumbers   []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(ctx context.Context, opts QueryPageOptions) (uint64, error)

func (*ReadStore) GetByIDs

func (s *ReadStore) GetByIDs(ctx context.Context, ids []string) ([]*Log, error)

func (*ReadStore) QueryPage

func (s *ReadStore) QueryPage(ctx context.Context, 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(ctx context.Context, e *event.Event) (err error)

func (*Sink) ReceiveNonBlockingEvent

func (s *Sink) ReceiveNonBlockingEvent(ctx context.Context, e *event.Event) (err error)

type WriteStore

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

func (*WriteStore) PersistLog

func (s *WriteStore) PersistLog(ctx context.Context, logEntry *Log) (err error)

Jump to

Keyboard shortcuts

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