fwstate

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FWStateServiceName        = fwstatepb.FWStateService_ServiceDesc.ServiceName
	FWStateMetricsServiceName = fwstatepb.MetricsService_ServiceDesc.ServiceName
)

FWStateServiceName and MetricsServiceName are the fully-qualified gRPC service names exposed by this module, derived from the generated service descriptors so they cannot drift from the proto definitions.

They are used to scope the module's grpcmetrics.ServerMetrics to its own services when several modules share a single grpc.Server.

Functions

func NewMetricsFactory

func NewMetricsFactory(extra ...grpcmetrics.Option) grpcmetrics.Factory

NewMetricsFactory returns a grpcmetrics.Factory pre-bound to this module's own labeler and service filter, applying any extra options (e.g. custom histogram buckets) supplied by the caller.

The grpcmetrics.Retention is injected by the service itself at construction time, so it must not be passed here.

Types

type Config

type Config struct {
	ffi.AttachConfig `yaml:",inline"`

	// Endpoint is the gRPC endpoint address
	Endpoint xcfg.NonEmptyString `yaml:"endpoint"`

	// StaleLayerSweepInterval is the period between stale-layer sweeps.
	StaleLayerSweepInterval time.Duration `yaml:"stale_layer_sweep_interval"`
}

Config represents FWState module configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

func (*Config) Default

func (m *Config) Default()

Default resets Config to DefaultConfig.

type FWStateModule

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

FWStateModule is a control-plane component of the firewall-state sync module.

The module shares state with ACL solely through named fwstate-map objects: the map service publishes them into the instance-wide config generation, where module configs of any agent resolve them by name.

func NewFWStateModule

func NewFWStateModule(cfg *Config, options ...Option) (*FWStateModule, error)

NewFWStateModule creates a new fwstate module instance.

func (*FWStateModule) Close

func (m *FWStateModule) Close() error

Close closes the module.

func (*FWStateModule) Endpoint

func (m *FWStateModule) Endpoint() string

func (*FWStateModule) Name

func (m *FWStateModule) Name() string

func (*FWStateModule) RegisterService

func (m *FWStateModule) RegisterService(server *grpc.Server)

func (*FWStateModule) Run added in v0.1.0

func (m *FWStateModule) Run(ctx context.Context) error

Run reclaims stale map layers until the context is cancelled.

The sweep publishes config generations through the module's agent, so it belongs to the phase that ends before anything is closed rather than to the module's own construction: a module whose ownership never transfers leaves nothing running behind it.

func (*FWStateModule) ServicesNames

func (m *FWStateModule) ServicesNames() []string

func (*FWStateModule) UnaryServerInterceptors

func (m *FWStateModule) UnaryServerInterceptors() []grpc.UnaryServerInterceptor

UnaryServerInterceptors returns the gRPC unary interceptors for this module.

type FWStateService

type FWStateService struct {
	fwstatepb.UnimplementedFWStateServiceServer
	// contains filtered or unexported fields
}

FWStateService implements the gRPC service for FWState management.

func NewFWStateService

func NewFWStateService(
	agent *ffi.Agent,
	options ...Option,
) *FWStateService

NewFWStateService creates a new FWState service.

When the WithMetrics option is supplied, gRPC call metrics are collected and exposed through the module's MetricsService.

func (*FWStateService) DeleteConfig

func (*FWStateService) ListConfigs

func (*FWStateService) Metrics

func (m *FWStateService) Metrics(tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)

Metrics returns FWState module metrics matching tags: dataplane counters and gRPC call metrics.

Labels:

  • config: fwstate config name (all metrics)
  • grpc_type: always "unary" (gRPC metrics)
  • grpc_service: fully-qualified gRPC service name (gRPC metrics)
  • grpc_method: RPC name (gRPC metrics)
  • grpc_code: gRPC status code string (grpc_server_handled_total only)

func (*FWStateService) ShowConfig

func (*FWStateService) UnaryServerInterceptor

func (m *FWStateService) UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns the service's gRPC metrics interceptor, or nil when metrics are not configured.

func (*FWStateService) UpdateConfig

type FwStateConfig

type FwStateConfig struct {
	*cfwstate.ModuleConfig
	// contains filtered or unexported fields
}

FwStateConfig is a service-owned fwstate module config plus the names of the fwstate-map objects it links, which the service needs for ShowConfig and for stats and entry reads delegated to the map objects.

The exposed snapshot — the map names and the sync settings — is captured at construction and never read back from shared memory, so readers may hold a config past its retirement: the Go values stay valid even after the shared-memory handle is freed.

func NewFWStateModuleConfig

func NewFWStateModuleConfig(
	agent *ffi.Agent,
	name string,
	old *FwStateConfig,
	syncConfig *fwstatepb.SyncConfig,
	fw4MapName, fw6MapName string,
) (*FwStateConfig, error)

NewFWStateModuleConfig builds the config in one step, ready to publish.

The request's sync settings merge over the values they replace, and each named map is declared as an object link resolving against published objects when the config is published. An empty map name declares no link, and the module then counts and drops that family's synced state. The map names are remembered only after the construction succeeds, so a failed construction leaves the previous linkage visible to readers.

func (*FwStateConfig) GetSyncConfig

func (m *FwStateConfig) GetSyncConfig() *fwstatepb.SyncConfig

func (*FwStateConfig) MapNameV4

func (m *FwStateConfig) MapNameV4() string

MapNameV4 returns the name of the linked IPv4 fwstate-map object.

func (*FwStateConfig) MapNameV6

func (m *FwStateConfig) MapNameV6() string

MapNameV6 returns the name of the linked IPv6 fwstate-map object.

type MetricsService

type MetricsService struct {
	fwstatepb.UnimplementedMetricsServiceServer
	// contains filtered or unexported fields
}

MetricsService exposes FWState module metrics over its own gRPC service.

It aggregates every source supplied at construction: the fwstate service's dataplane counters and gRPC call metrics, plus the map service's per-map gauge series and gRPC call metrics for the RPCs the module also serves.

func NewMetricsService

func NewMetricsService(sources ...metricsSource) *MetricsService

NewMetricsService creates a MetricsService backed by sources.

func (*MetricsService) GetMetrics

GetMetrics returns a snapshot of FWState module metrics matching the request's tags.

type MutationObserver

type MutationObserver interface {
	ObserveFWStateMutation(operation, phase string)
}

MutationObserver observes a mutation's lifecycle in the config store: before it enters the store's writer section, once an admitted mutation is about to touch shared memory inside that section, and as that work ends. A mutation the store rejects before running it — a delete of an unknown name — reports only the first phase. It observes synchronization but never controls it, and lets tests prove ordering between concurrent mutations.

type Option

type Option func(*options)

Option configures an FWStateService.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the service logger.

func WithMetrics

func WithMetrics(factory grpcmetrics.Factory) Option

WithMetrics enables collection of gRPC call metrics using the supplied factory.

The factory owns label extraction and bucketing. The service injects its own retention provider at construction time. Use NewMetricsFactory to build a factory scoped to this module's services.

func WithMutationObserver

func WithMutationObserver(observer MutationObserver) Option

WithMutationObserver installs an observer receiving every mutation's lock lifecycle events.

Directories

Path Synopsis
fwstatepb
v1

Jump to

Keyboard shortcuts

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