examples

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package examples contains example plugin implementations for AegisGate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsMetrics

type AnalyticsMetrics struct {
	TotalRequests  int64
	TotalResponses int64
	TotalBytesIn   int64
	TotalBytesOut  int64
	AvgLatency     time.Duration
	TopPaths       map[string]int
	StatusCodes    map[int]int
}

AnalyticsMetrics holds analytics data

type ExampleAnalyticsPlugin

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

ExampleAnalyticsPlugin demonstrates an analytics plugin

func NewExampleAnalyticsPlugin

func NewExampleAnalyticsPlugin() *ExampleAnalyticsPlugin

NewExampleAnalyticsPlugin creates a new analytics plugin

func (*ExampleAnalyticsPlugin) GetMetrics

func (p *ExampleAnalyticsPlugin) GetMetrics() *AnalyticsMetrics

GetMetrics returns the analytics metrics

func (*ExampleAnalyticsPlugin) Hooks

func (p *ExampleAnalyticsPlugin) Hooks() []plugin.HookType

Hooks returns the hooks this plugin implements

func (*ExampleAnalyticsPlugin) Init

Init initializes the plugin

func (*ExampleAnalyticsPlugin) Metadata

Metadata returns the plugin metadata

func (*ExampleAnalyticsPlugin) ProcessRequest

func (p *ExampleAnalyticsPlugin) ProcessRequest(ctx context.Context, reqCtx *plugin.RequestContext) (*plugin.HookResult, error)

ProcessRequest tracks request metrics

func (*ExampleAnalyticsPlugin) ProcessResponse

ProcessResponse tracks response metrics

func (*ExampleAnalyticsPlugin) Start

Start starts the plugin

func (*ExampleAnalyticsPlugin) Stop

Stop stops the plugin

type ExampleFilterPlugin

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

ExampleFilterPlugin is a simple filter plugin that logs requests and responses. This demonstrates how to implement a filter plugin.

func NewExampleFilterPlugin

func NewExampleFilterPlugin() *ExampleFilterPlugin

NewExampleFilterPlugin creates a new example filter plugin

func (*ExampleFilterPlugin) GetStats

func (p *ExampleFilterPlugin) GetStats() *FilterStats

GetStats returns the filter statistics

func (*ExampleFilterPlugin) Hooks

func (p *ExampleFilterPlugin) Hooks() []plugin.HookType

Hooks returns the hooks this plugin implements

func (*ExampleFilterPlugin) Init

Init initializes the plugin

func (*ExampleFilterPlugin) Metadata

Metadata returns the plugin metadata

func (*ExampleFilterPlugin) OnError

func (p *ExampleFilterPlugin) OnError(ctx context.Context, errCtx *plugin.ErrorContext) error

OnError handles errors (for ErrorHandler interface)

func (*ExampleFilterPlugin) ProcessRequest

func (p *ExampleFilterPlugin) ProcessRequest(ctx context.Context, reqCtx *plugin.RequestContext) (*plugin.HookResult, error)

ProcessRequest handles the request received hook

func (*ExampleFilterPlugin) ProcessResponse

func (p *ExampleFilterPlugin) ProcessResponse(ctx context.Context, reqCtx *plugin.RequestContext, respCtx *plugin.ResponseContext) (*plugin.HookResult, error)

ProcessResponse handles the response sent hook

func (*ExampleFilterPlugin) Start

func (p *ExampleFilterPlugin) Start(ctx context.Context) error

Start starts the plugin

func (*ExampleFilterPlugin) Stop

Stop stops the plugin

type ExamplePeriodicPlugin

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

ExamplePeriodicPlugin demonstrates a plugin with periodic tasks

func NewExamplePeriodicPlugin

func NewExamplePeriodicPlugin() *ExamplePeriodicPlugin

NewExamplePeriodicPlugin creates a new periodic task plugin

func (*ExamplePeriodicPlugin) GetTaskCount

func (p *ExamplePeriodicPlugin) GetTaskCount() int

GetTaskCount returns the number of tasks executed

func (*ExamplePeriodicPlugin) Hooks

func (p *ExamplePeriodicPlugin) Hooks() []plugin.HookType

Hooks returns the hooks this plugin implements

func (*ExamplePeriodicPlugin) Init

Init initializes the plugin

func (*ExamplePeriodicPlugin) Interval

func (p *ExamplePeriodicPlugin) Interval() time.Duration

Interval returns the interval for periodic tasks

func (*ExamplePeriodicPlugin) Metadata

Metadata returns the plugin metadata

func (*ExamplePeriodicPlugin) OnPeriodic

func (p *ExamplePeriodicPlugin) OnPeriodic(ctx context.Context, periodicCtx *plugin.PeriodicContext) error

OnPeriodic runs the periodic task

func (*ExamplePeriodicPlugin) Start

Start starts the plugin

func (*ExamplePeriodicPlugin) Stop

Stop stops the plugin

type FilterStats

type FilterStats struct {
	RequestsProcessed  int64
	ResponsesProcessed int64
	Errors             int64
}

FilterStats tracks filter statistics

Jump to

Keyboard shortcuts

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