core

package
v0.0.0-...-6cfc1b2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package core is a generated GoMock package.

Index

Constants

View Source
const AlertAnnotation = "ALERT"
View Source
const BaseHTTPPath = "/api/modules"

Variables

View Source
var (
	AlertInfoAnn     = Annotation{Name: AlertAnnotation, Annotation: []byte(AlertInfo.String())}
	AlertWarnAnn     = Annotation{Name: AlertAnnotation, Annotation: []byte(AlertWarn.String())}
	AlertCriticalAnn = Annotation{Name: AlertAnnotation, Annotation: []byte(AlertCritical.String())}
)

Functions

func GetAssetsDir

func GetAssetsDir() string

GetAssetsDir get assets directory from env variable or the default location.

func New

func New(ctx context.Context, accessor BackendAccessor, samplingManager *sampling.TraceSamplingManager, traceSamplingEnabled bool) (Module, []ModuleInfo)

func RegisterModule

func RegisterModule(m ModuleFactory)

Types

type AlertSeverity

type AlertSeverity int
const (
	AlertInfo AlertSeverity = iota
	AlertWarn
	AlertCritical
)

func (AlertSeverity) String

func (es AlertSeverity) String() string

type Annotation

type Annotation struct {
	Name       string
	Annotation []byte
}

type BackendAccessor

type BackendAccessor interface {
	K8SClient() kubernetes.Interface
	GetSpeculatorAccessor() speculatoraccessor.SpeculatorsAccessor
	GetTraceSamplingAccessor() *sampling.TraceSamplingManager

	GetAPIInfo(ctx context.Context, apiID uint) (*database.APIInfo, error)
	GetAPIEvents(ctx context.Context, filter database.GetAPIEventsQuery) ([]*database.APIEvent, error)
	UpdateAPIEvent(ctx context.Context, event *database.APIEvent) error

	GetAPIEventAnnotation(ctx context.Context, modName string, eventID uint, name string) (*Annotation, error)
	ListAPIEventAnnotations(ctx context.Context, modName string, eventID uint) ([]*Annotation, error)
	CreateAPIEventAnnotations(ctx context.Context, modName string, eventID uint, annotations ...Annotation) error

	GetAPIInfoAnnotation(ctx context.Context, modName string, apiID uint, name string) (*Annotation, error)
	ListAPIInfoAnnotations(ctx context.Context, modName string, apiID uint) ([]*Annotation, error)
	StoreAPIInfoAnnotations(ctx context.Context, modName string, apiID uint, annotations ...Annotation) error
	DeleteAPIInfoAnnotations(ctx context.Context, modName string, apiID uint, name ...string) error
	DeleteAllAPIInfoAnnotations(ctx context.Context, modName string, apiID uint) error

	EnableTraces(ctx context.Context, modName string, apiID uint) error
	DisableTraces(ctx context.Context, modName string, apiID uint) error

	Notify(ctx context.Context, modName string, apiID uint, notification notifications.APIClarityNotification) error
}

func NewAccessor

func NewAccessor(dbHandler *database.Handler, clientset kubernetes.Interface, samplingManager *sampling.TraceSamplingManager, speculatorAccessor speculatoraccessor.SpeculatorsAccessor, notifier *notifier.Notifier, conf *config.Config) (BackendAccessor, error)

type Core

type Core struct {
	Modules map[string]Module
	// contains filtered or unexported fields
}

func (*Core) EventNotify

func (c *Core) EventNotify(ctx context.Context, event *Event)

func (*Core) HTTPHandler

func (c *Core) HTTPHandler() http.Handler

func (*Core) Info

func (c *Core) Info() ModuleInfo

type Event

type Event struct {
	APIEvent  *database.APIEvent
	APIInfo   *database.APIInfo
	Telemetry *pluginsmodels.Telemetry
}

type MockBackendAccessor

type MockBackendAccessor struct {
	// contains filtered or unexported fields
}

MockBackendAccessor is a mock of BackendAccessor interface.

func NewMockBackendAccessor

func NewMockBackendAccessor(ctrl *gomock.Controller) *MockBackendAccessor

NewMockBackendAccessor creates a new mock instance.

func (*MockBackendAccessor) CreateAPIEventAnnotations

func (m *MockBackendAccessor) CreateAPIEventAnnotations(arg0 context.Context, arg1 string, arg2 uint, arg3 ...Annotation) error

CreateAPIEventAnnotations mocks base method.

func (*MockBackendAccessor) DeleteAPIInfoAnnotations

func (m *MockBackendAccessor) DeleteAPIInfoAnnotations(arg0 context.Context, arg1 string, arg2 uint, arg3 ...string) error

DeleteAPIInfoAnnotations mocks base method.

func (*MockBackendAccessor) DeleteAllAPIInfoAnnotations

func (m *MockBackendAccessor) DeleteAllAPIInfoAnnotations(arg0 context.Context, arg1 string, arg2 uint) error

DeleteAllAPIInfoAnnotations mocks base method.

func (*MockBackendAccessor) DisableTraces

func (m *MockBackendAccessor) DisableTraces(arg0 context.Context, arg1 string, arg2 uint) error

DisableTraces mocks base method.

func (*MockBackendAccessor) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBackendAccessor) EnableTraces

func (m *MockBackendAccessor) EnableTraces(arg0 context.Context, arg1 string, arg2 uint) error

EnableTraces mocks base method.

func (*MockBackendAccessor) GetAPIEventAnnotation

func (m *MockBackendAccessor) GetAPIEventAnnotation(arg0 context.Context, arg1 string, arg2 uint, arg3 string) (*Annotation, error)

GetAPIEventAnnotation mocks base method.

func (*MockBackendAccessor) GetAPIEvents

GetAPIEvents mocks base method.

func (*MockBackendAccessor) GetAPIInfo

func (m *MockBackendAccessor) GetAPIInfo(arg0 context.Context, arg1 uint) (*database.APIInfo, error)

GetAPIInfo mocks base method.

func (*MockBackendAccessor) GetAPIInfoAnnotation

func (m *MockBackendAccessor) GetAPIInfoAnnotation(arg0 context.Context, arg1 string, arg2 uint, arg3 string) (*Annotation, error)

GetAPIInfoAnnotation mocks base method.

func (*MockBackendAccessor) GetSpeculatorAccessor

func (m *MockBackendAccessor) GetSpeculatorAccessor() speculatoraccessor.SpeculatorsAccessor

GetSpeculatorAccessor mocks base method.

func (*MockBackendAccessor) GetTraceSamplingAccessor

func (m *MockBackendAccessor) GetTraceSamplingAccessor() *sampling.TraceSamplingManager

GetTraceSamplingAccessor mocks base method.

func (*MockBackendAccessor) K8SClient

func (m *MockBackendAccessor) K8SClient() kubernetes.Interface

K8SClient mocks base method.

func (*MockBackendAccessor) ListAPIEventAnnotations

func (m *MockBackendAccessor) ListAPIEventAnnotations(arg0 context.Context, arg1 string, arg2 uint) ([]*Annotation, error)

ListAPIEventAnnotations mocks base method.

func (*MockBackendAccessor) ListAPIInfoAnnotations

func (m *MockBackendAccessor) ListAPIInfoAnnotations(arg0 context.Context, arg1 string, arg2 uint) ([]*Annotation, error)

ListAPIInfoAnnotations mocks base method.

func (*MockBackendAccessor) Notify

Notify mocks base method.

func (*MockBackendAccessor) StoreAPIInfoAnnotations

func (m *MockBackendAccessor) StoreAPIInfoAnnotations(arg0 context.Context, arg1 string, arg2 uint, arg3 ...Annotation) error

StoreAPIInfoAnnotations mocks base method.

func (*MockBackendAccessor) UpdateAPIEvent

func (m *MockBackendAccessor) UpdateAPIEvent(arg0 context.Context, arg1 *database.APIEvent) error

UpdateAPIEvent mocks base method.

type MockBackendAccessorMockRecorder

type MockBackendAccessorMockRecorder struct {
	// contains filtered or unexported fields
}

MockBackendAccessorMockRecorder is the mock recorder for MockBackendAccessor.

func (*MockBackendAccessorMockRecorder) CreateAPIEventAnnotations

func (mr *MockBackendAccessorMockRecorder) CreateAPIEventAnnotations(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

CreateAPIEventAnnotations indicates an expected call of CreateAPIEventAnnotations.

func (*MockBackendAccessorMockRecorder) DeleteAPIInfoAnnotations

func (mr *MockBackendAccessorMockRecorder) DeleteAPIInfoAnnotations(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

DeleteAPIInfoAnnotations indicates an expected call of DeleteAPIInfoAnnotations.

func (*MockBackendAccessorMockRecorder) DeleteAllAPIInfoAnnotations

func (mr *MockBackendAccessorMockRecorder) DeleteAllAPIInfoAnnotations(arg0, arg1, arg2 interface{}) *gomock.Call

DeleteAllAPIInfoAnnotations indicates an expected call of DeleteAllAPIInfoAnnotations.

func (*MockBackendAccessorMockRecorder) DisableTraces

func (mr *MockBackendAccessorMockRecorder) DisableTraces(arg0, arg1, arg2 interface{}) *gomock.Call

DisableTraces indicates an expected call of DisableTraces.

func (*MockBackendAccessorMockRecorder) EnableTraces

func (mr *MockBackendAccessorMockRecorder) EnableTraces(arg0, arg1, arg2 interface{}) *gomock.Call

EnableTraces indicates an expected call of EnableTraces.

func (*MockBackendAccessorMockRecorder) GetAPIEventAnnotation

func (mr *MockBackendAccessorMockRecorder) GetAPIEventAnnotation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

GetAPIEventAnnotation indicates an expected call of GetAPIEventAnnotation.

func (*MockBackendAccessorMockRecorder) GetAPIEvents

func (mr *MockBackendAccessorMockRecorder) GetAPIEvents(arg0, arg1 interface{}) *gomock.Call

GetAPIEvents indicates an expected call of GetAPIEvents.

func (*MockBackendAccessorMockRecorder) GetAPIInfo

func (mr *MockBackendAccessorMockRecorder) GetAPIInfo(arg0, arg1 interface{}) *gomock.Call

GetAPIInfo indicates an expected call of GetAPIInfo.

func (*MockBackendAccessorMockRecorder) GetAPIInfoAnnotation

func (mr *MockBackendAccessorMockRecorder) GetAPIInfoAnnotation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

GetAPIInfoAnnotation indicates an expected call of GetAPIInfoAnnotation.

func (*MockBackendAccessorMockRecorder) GetSpeculatorAccessor

func (mr *MockBackendAccessorMockRecorder) GetSpeculatorAccessor() *gomock.Call

GetSpeculatorAccessor indicates an expected call of GetSpeculatorAccessor.

func (*MockBackendAccessorMockRecorder) GetTraceSamplingAccessor

func (mr *MockBackendAccessorMockRecorder) GetTraceSamplingAccessor() *gomock.Call

GetTraceSamplingAccessor indicates an expected call of GetTraceSamplingAccessor.

func (*MockBackendAccessorMockRecorder) K8SClient

func (mr *MockBackendAccessorMockRecorder) K8SClient() *gomock.Call

K8SClient indicates an expected call of K8SClient.

func (*MockBackendAccessorMockRecorder) ListAPIEventAnnotations

func (mr *MockBackendAccessorMockRecorder) ListAPIEventAnnotations(arg0, arg1, arg2 interface{}) *gomock.Call

ListAPIEventAnnotations indicates an expected call of ListAPIEventAnnotations.

func (*MockBackendAccessorMockRecorder) ListAPIInfoAnnotations

func (mr *MockBackendAccessorMockRecorder) ListAPIInfoAnnotations(arg0, arg1, arg2 interface{}) *gomock.Call

ListAPIInfoAnnotations indicates an expected call of ListAPIInfoAnnotations.

func (*MockBackendAccessorMockRecorder) Notify

func (mr *MockBackendAccessorMockRecorder) Notify(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Notify indicates an expected call of Notify.

func (*MockBackendAccessorMockRecorder) StoreAPIInfoAnnotations

func (mr *MockBackendAccessorMockRecorder) StoreAPIInfoAnnotations(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

StoreAPIInfoAnnotations indicates an expected call of StoreAPIInfoAnnotations.

func (*MockBackendAccessorMockRecorder) UpdateAPIEvent

func (mr *MockBackendAccessorMockRecorder) UpdateAPIEvent(arg0, arg1 interface{}) *gomock.Call

UpdateAPIEvent indicates an expected call of UpdateAPIEvent.

type MockModule

type MockModule struct {
	// contains filtered or unexported fields
}

MockModule is a mock of Module interface.

func NewMockModule

func NewMockModule(ctrl *gomock.Controller) *MockModule

NewMockModule creates a new mock instance.

func (*MockModule) EXPECT

func (m *MockModule) EXPECT() *MockModuleMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockModule) EventNotify

func (m *MockModule) EventNotify(arg0 context.Context, arg1 *Event)

EventNotify mocks base method.

func (*MockModule) HTTPHandler

func (m *MockModule) HTTPHandler() http.Handler

HTTPHandler mocks base method.

func (*MockModule) Info

func (m *MockModule) Info() ModuleInfo

Info mocks base method.

type MockModuleMockRecorder

type MockModuleMockRecorder struct {
	// contains filtered or unexported fields
}

MockModuleMockRecorder is the mock recorder for MockModule.

func (*MockModuleMockRecorder) EventNotify

func (mr *MockModuleMockRecorder) EventNotify(arg0, arg1 interface{}) *gomock.Call

EventNotify indicates an expected call of EventNotify.

func (*MockModuleMockRecorder) HTTPHandler

func (mr *MockModuleMockRecorder) HTTPHandler() *gomock.Call

HTTPHandler indicates an expected call of HTTPHandler.

func (*MockModuleMockRecorder) Info

func (mr *MockModuleMockRecorder) Info() *gomock.Call

Info indicates an expected call of Info.

type Module

type Module interface {
	Info() ModuleInfo

	// EventNotify called when a new API Request/reply is received by APIClarity.
	EventNotify(ctx context.Context, event *Event)

	// HTTPHandler that will be served by APIClarity under /api/modules/{moduleName}
	HTTPHandler() http.Handler
}

Module each APIClarity module needs to implement this interface.

type ModuleFactory

type ModuleFactory func(ctx context.Context, accessor BackendAccessor) (Module, error)

type ModuleInfo

type ModuleInfo struct {
	Name        string
	Description string
}

Jump to

Keyboard shortcuts

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