Help us shape the future of Go! Take the 2026 Go Developer Survey

network

package
v1.15.18 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package network is the facade of the network module: admin-side server and node management, the node-facing server API and the edge client manifest. See docs/adr-001-modular-monolith.md.

Index

Constants

This section is empty.

Variables

View Source
var ErrManifestNotFound = edge.ErrManifestNotFound

ErrManifestNotFound re-exports the edge subdomain's not-found sentinel for the transport handler's status mapping.

Functions

func NewRepoBuilder added in v1.15.2

func NewRepoBuilder(rds *redis.Client) repository.NetworkBuilder

NewRepoBuilder exports the module-owned repository implementations for store assembly. The node cache retrier is a background singleton that survives per-transaction rebuilds, so it lives in this closure (ADR-001 step-6 preparation).

Types

type Deps

type Deps struct {
	Store repository.Store
	Redis *redis.Client
	// Config snapshots the runtime-mutable settings per request.
	Config func() Snapshot
	// Multiplier returns the node traffic multiplier in effect at the given
	// time; nil means no multiplier is configured.
	Multiplier func(at time.Time) float32
}

Deps declares everything the module needs; the composition root (internal/svc) provides them. The module wraps the legacy store during migration and will own its persistence once the domain data moves in (ADR-001 step 5).

type RequestMeta

type RequestMeta = serverapi.RequestMeta

RequestMeta and ResponseMeta re-export the server API's conditional-request negotiation types for the transport handlers.

type ResponseMeta

type ResponseMeta = serverapi.ResponseMeta

RequestMeta and ResponseMeta re-export the server API's conditional-request negotiation types for the transport handlers.

type Service

type Service interface {
	// Admin-side server and node management.
	CreateServer(ctx context.Context, req *dto.CreateServerRequest) error
	UpdateServer(ctx context.Context, req *dto.UpdateServerRequest) error
	DeleteServer(ctx context.Context, req *dto.DeleteServerRequest) error
	FilterServerList(ctx context.Context, req *dto.FilterServerListRequest) (*dto.FilterServerListResponse, error)
	ResetSortWithServer(ctx context.Context, req *dto.ResetSortRequest) error
	GetServerProtocols(ctx context.Context, req *dto.GetServerProtocolsRequest) (*dto.GetServerProtocolsResponse, error)
	GetServerNodeConfig(ctx context.Context, req *dto.GetServerNodeConfigRequest) (*dto.GetServerNodeConfigResponse, error)
	UpdateServerNodeConfig(ctx context.Context, req *dto.UpdateServerNodeConfigRequest) error
	CreateNode(ctx context.Context, req *dto.CreateNodeRequest) error
	UpdateNode(ctx context.Context, req *dto.UpdateNodeRequest) error
	DeleteNode(ctx context.Context, req *dto.DeleteNodeRequest) error
	FilterNodeList(ctx context.Context, req *dto.FilterNodeListRequest) (*dto.FilterNodeListResponse, error)
	ToggleNodeStatus(ctx context.Context, req *dto.ToggleNodeStatusRequest) error
	ResetSortWithNode(ctx context.Context, req *dto.ResetSortRequest) error
	QueryNodeTag(ctx context.Context) (*dto.QueryNodeTagResponse, error)

	// The node-facing server API. The ETag negotiation flows through
	// RequestMeta/ResponseMeta; node authentication stays in the handlers.
	GetServerConfig(ctx context.Context, req *dto.GetServerConfigRequest, meta RequestMeta) (*dto.GetServerConfigResponse, ResponseMeta, error)
	GetServerUserList(ctx context.Context, req *dto.GetServerUserListRequest, meta RequestMeta) (*dto.GetServerUserListResponse, ResponseMeta, error)
	QueryServerProtocolConfig(ctx context.Context, req *dto.QueryServerConfigRequest) (*dto.QueryServerConfigResponse, error)
	PushOnlineUsers(ctx context.Context, req *dto.OnlineUsersRequest) error
	ServerPushStatus(ctx context.Context, req *dto.ServerPushStatusRequest) error
	ServerPushUserTraffic(ctx context.Context, req *dto.ServerPushUserTrafficRequest) error

	// EdgeManifest serves the token-authenticated edge client manifest.
	EdgeManifest(ctx context.Context, token string) (*dto.EdgeManifestResponse, error)
}

Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.

func New

func New(deps Deps) Service

type Snapshot

type Snapshot struct {
	Node      config.NodeConfig
	Subscribe config.SubscribeConfig
}

Snapshot is the per-request view of the runtime-mutable settings the network flows consume.

Directories

Path Synopsis
entity
internal
adminserver
Service assembly for the admin-side server and node management subdomain of the network module.
Service assembly for the admin-side server and node management subdomain of the network module.
edge
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
serverapi
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.

Jump to

Keyboard shortcuts

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