Documentation
¶
Overview ¶
Package vmflow provides an embeddable L4 forwarding runtime for TCP and UDP rules. It can be used directly by larger Go control planes or through the standalone vmflow daemon and CLI.
Index ¶
- Variables
- type CertProvider
- type Options
- type Runtime
- func (r *Runtime) Apply(rules []engine.Rule) engine.ApplyResult
- func (r *Runtime) ApplySnapshot(rules []engine.Rule, opts engine.ApplySnapshotOptions) engine.ApplyResult
- func (r *Runtime) Close() error
- func (r *Runtime) Collector() *engine.Collector
- func (r *Runtime) Manager() *engine.Manager
- func (r *Runtime) RemoveRule(ruleID string)
- func (r *Runtime) RestartRule(rule engine.Rule) error
- func (r *Runtime) RunningCount() int
- func (r *Runtime) RunningRules() []engine.Rule
- func (r *Runtime) Shutdown(ctx context.Context) error
- func (r *Runtime) Snapshot(ruleID string) engine.TrafficSnapshot
- func (r *Runtime) SnapshotAll() []engine.TrafficSnapshot
- func (r *Runtime) StartRule(rule engine.Rule) error
- func (r *Runtime) StopAll()
- func (r *Runtime) StopRule(ruleID string)
Constants ¶
This section is empty.
Variables ¶
var ErrRuntimeClosed = errors.New("vmflow runtime closed")
ErrRuntimeClosed is returned when callers try to mutate a closed Runtime.
Functions ¶
This section is empty.
Types ¶
type CertProvider ¶
type CertProvider = engine.CertProvider
CertProvider is the certificate provider interface used by HTTPS rules. It is an alias of engine.CertProvider so embedders can depend on the top-level vmflow package without importing engine for certificate wiring.
type Options ¶
type Options struct {
// Collector can be supplied when the host application wants to share or wrap
// the vmflow in-memory traffic counters. If nil, a new collector is created.
Collector *engine.Collector
// CertProvider enables HTTPS rules. Leave nil when the embedded application
// only uses TCP, UDP, tcp+udp, or HTTP proxy rules.
CertProvider CertProvider
}
Options controls construction of an embedded Runtime.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is a small embeddable facade over the forwarding engine.
Use Runtime when vmflow is embedded into a larger control plane such as vmpulse. The larger application remains responsible for configuration, persistence, authentication, and business logic; Runtime owns only the in-process forwarding manager and real-time counters.
func NewRuntime ¶
NewRuntime creates a new embeddable forwarding runtime.
func (*Runtime) Apply ¶
func (r *Runtime) Apply(rules []engine.Rule) engine.ApplyResult
Apply applies a full replacement snapshot. This is the usual mode for an embedded control plane that calculates desired state from its own database.
func (*Runtime) ApplySnapshot ¶
func (r *Runtime) ApplySnapshot(rules []engine.Rule, opts engine.ApplySnapshotOptions) engine.ApplyResult
ApplySnapshot applies rules with explicit options.
func (*Runtime) Manager ¶
Manager returns the underlying engine manager for advanced use cases. Prefer the facade methods on Runtime when possible.
func (*Runtime) RemoveRule ¶
RemoveRule stops a single rule and removes its counters.
func (*Runtime) RestartRule ¶
RestartRule restarts or starts a single rule.
func (*Runtime) RunningCount ¶
RunningCount returns the number of currently running rules.
func (*Runtime) RunningRules ¶
RunningRules returns the currently running rules sorted by rule_id.
func (*Runtime) Shutdown ¶
Shutdown stops the runtime. The current implementation stops synchronously; the context is accepted to keep the embedding API forward-compatible with future graceful drain support.
func (*Runtime) Snapshot ¶
func (r *Runtime) Snapshot(ruleID string) engine.TrafficSnapshot
Snapshot returns one rule's in-memory traffic snapshot.
func (*Runtime) SnapshotAll ¶
func (r *Runtime) SnapshotAll() []engine.TrafficSnapshot
SnapshotAll returns all in-memory traffic snapshots sorted by rule_id.