connectionpolicy

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 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

Overview

Package connectionpolicy defines the default reaction to a discovered device.

Policy evaluates discovery state only. It never opens an endpoint, creates a Session, or asks a user for input; those actions remain the responsibility of the client that consumes a decision.

Index

Constants

View Source
const Default = PolicyAsk

Default is the safe policy used when configuration does not specify one.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action identifies the next step a client should take after evaluating a device-discovery event.

const (
	// ActionNone means no discovery-driven action should be taken.
	ActionNone Action = "none"
	// ActionAsk requires the client to ask the user before opening the endpoint.
	ActionAsk Action = "ask"
	// ActionConnect permits the client to open the endpoint without a further
	// approval prompt.
	ActionConnect Action = "connect"
	// ActionDeny tells the client to ignore the discovery event without asking.
	ActionDeny Action = "deny"
)

func Decide

func Decide(policy Policy, present, connected bool) Action

Decide returns the discovery-driven action for one endpoint.

An absent device and an endpoint with an active Session both take precedence over the configured policy. This prevents a second Session from being opened for an endpoint that is already within an active lifecycle stage.

type Policy

type Policy string

Policy identifies the default client reaction to a newly discovered endpoint.

const (
	// PolicyAsk requires the client to obtain the user's approval before opening
	// a discovered endpoint.
	PolicyAsk Policy = "ask"
	// PolicyAuto permits the client to open a discovered endpoint without asking
	// for approval first when it has sufficient connection parameters.
	PolicyAuto Policy = "auto"
	// PolicyDeny tells the client to ignore a discovered endpoint. It does not
	// restrict an explicit user-requested connection.
	PolicyDeny Policy = "deny"
)

func FromConfig

func FromConfig(value string) (Policy, error)

FromConfig resolves an optional configuration value, using Default when the field is omitted. A non-empty unrecognized value is rejected rather than silently changing the user's intended connection behavior.

func Parse

func Parse(value string) (Policy, error)

Parse validates an explicitly supplied policy value.

Jump to

Keyboard shortcuts

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