Documentation
¶
Overview ¶
Package probe provides functionality to gather and manage server information for a Minecraft server. It includes methods to retrieve server configuration, mod list, executable information, and other relevant details. The package utilizes memoization to avoid redundant calculations and resolve any data dependencies issues. Therefore, all probe functions are 100% concurrent-safe.
The main exposed function is ServerInfo, which returns a comprehensive ServerInfo struct containing all the gathered information. To avoid side effects, the ServerInfo struct is returned as a copy, rather than reference.
Package probe provides functionality to gather and manage server information for a Minecraft server. It includes methods to retrieve server configuration, mod list, executable information, and other relevant details. The package utilizes memoization to avoid redundant calculations and resolve any data dependencies issues. Therefore, all probe functions are 100% concurrent-safe.
The main exposed function is ServerInfo, which returns a comprehensive ServerInfo struct containing all the gathered information. To avoid side effects, the ServerInfo struct is returned as a copy, rather than reference.
Index ¶
- Variables
- func BuildTopologyFromEntry(entry RegistryEntry) *types.RuntimeTopology
- func CapabilityForPlatform(p types.Platform) types.RuntimeCapability
- func DetectPackages(filePath string) []types.Package
- func EnrichTopologyFromPackages(exec *ServerRuntime, packages []types.Package)
- func EvaluateCompatibility(topology *types.RuntimeTopology, requiredCapability types.RuntimeCapability) types.CompatResult
- func FoldTopologyRisk(t *types.RuntimeTopology)
- func InvalidateServerInfo()
- func NormalizeRuntimeID(name string) types.RuntimeNodeID
- func NormalizeTopology(t *types.RuntimeTopology)
- func Rebuild()
- func RuntimeIdentityNode(identity types.PackageId) (types.RuntimeNodeID, bool)
- type PackageIndex
- func (idx *PackageIndex) Add(pkg types.Package)
- func (idx *PackageIndex) LookupByID(id types.PackageId) (types.Package, bool)
- func (idx *PackageIndex) LookupByPlatformName(platform types.Platform, name string) []types.Package
- func (idx *PackageIndex) Merge(pkgs []types.Package)
- func (idx *PackageIndex) Packages() []types.Package
- type RegistryEdge
- type RegistryEntry
- type RuntimeRegistry
- type ServerRuntime
- func (e *ServerRuntime) Analyzable() bool
- func (e *ServerRuntime) DerivedLoaderVersion() string
- func (e *ServerRuntime) DerivedModLoader() types.Platform
- func (e *ServerRuntime) DerivedServerCore() string
- func (e *ServerRuntime) IsValid() bool
- func (e *ServerRuntime) PrimaryRuntimeIdentity() *types.PackageId
- func (e *ServerRuntime) RuntimeIdentityPackage(node *types.TopologyNode) *types.PackageId
- type Workspace
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRuntimeRegistry(defaultRegistryEntries)
var NoExecutable = &ServerRuntime{ PrimaryEntrance: "", GameVersion: types.VersionNone, BootCommand: nil, Topology: types.TopologyEmpty, }
var UnknownExecutable = &ServerRuntime{ PrimaryEntrance: "", GameVersion: types.VersionUnknown, BootCommand: nil, Topology: types.TopologyUnknown, }
Functions ¶
func BuildTopologyFromEntry ¶
func BuildTopologyFromEntry(entry RegistryEntry) *types.RuntimeTopology
BuildTopologyFromEntry constructs a RuntimeTopology with a single primary node from a registry entry, plus any policy edges listed.
func CapabilityForPlatform ¶
func CapabilityForPlatform(p types.Platform) types.RuntimeCapability
CapabilityForPlatform maps a package's Platform identity to the RuntimeCapability it requires in the host server's topology. Returns empty string if no mapping exists.
func DetectPackages ¶
DetectPackages analyzes a local artifact file and returns packages detected from its embedded metadata.
func EnrichTopologyFromPackages ¶
func EnrichTopologyFromPackages( exec *ServerRuntime, packages []types.Package, )
func EvaluateCompatibility ¶
func EvaluateCompatibility(topology *types.RuntimeTopology, requiredCapability types.RuntimeCapability) types.CompatResult
PURE POLICY LAYER: These evaluators are deterministic and side-effect free. They take topology values as input and return compatibility verdicts. No file I/O, no network calls, no logging, no panic.
EvaluateCompatibility evaluates whether a server runtime (described by topology) can support the requested ecosystem. Verdict encodes direct support, indirect/hosted support, incompatibility, or unresolved topology. Indirect support is reported as CompatDegraded, while runtime risk remains a node-level topology concern. Never returns nil - always returns a deterministic result.
func FoldTopologyRisk ¶
func FoldTopologyRisk(t *types.RuntimeTopology)
FoldTopologyRisk propagates the maximum node risk level across all connected components by repeatedly folding each edge's endpoints to their maximum risk. Safe to call on nil or unresolved topologies.
func InvalidateServerInfo ¶
func InvalidateServerInfo()
InvalidateServerInfo marks the cached ServerInfo as stale so the next call to ServerInfo() will re-probe the server state. This is useful after installing packages (e.g., identity packages like Fabric) to refresh the topology cache without forcing an immediate rebuild.
func NormalizeRuntimeID ¶
func NormalizeRuntimeID(name string) types.RuntimeNodeID
func NormalizeTopology ¶
func NormalizeTopology(t *types.RuntimeTopology)
NormalizeTopology deduplicates nodes (by ID, last-write wins) and edges (by From+To+Kind triple), then sorts both slices for deterministic output. Safe to call on nil or unresolved topologies.
func Rebuild ¶
func Rebuild()
Rebuild forces ServerInfo to be regenerated and blocks all readers while rebuilding.
func RuntimeIdentityNode ¶
func RuntimeIdentityNode(identity types.PackageId) (types.RuntimeNodeID, bool)
Types ¶
type PackageIndex ¶
type PackageIndex struct {
// contains filtered or unexported fields
}
PackageIndex is a map-backed package indexing utility that provides deterministic, sorted access to a collection of packages. It deduplicates packages by their full identifier (PackageId.StringFull()) and guarantees that all exported methods return results in a stable, deterministic order.
PackageIndex does NOT expose raw map iteration order to any caller.
func NewPackageIndex ¶
func NewPackageIndex() *PackageIndex
NewPackageIndex creates a new, empty PackageIndex ready for use.
func (*PackageIndex) Add ¶
func (idx *PackageIndex) Add(pkg types.Package)
Add inserts a package into the index with the following dedupe policy:
- First-write wins: if a package with the same full ID already exists, the new entry is ignored.
- EXCEPTION: if the existing entry has an empty Local.Path (i.e., it was discovered without a local installation path) AND the new package has a non-empty Local.Path, the new package replaces the existing one. This allows local-path enrichment to take precedence over remote-only entries.
The dedupe key is pkg.Id.StringFull(), which encodes platform/name@version.
func (*PackageIndex) LookupByID ¶
LookupByID performs an exact lookup by the full package identifier (PackageId.StringFull()). Returns the package and true if found, or a zero Package and false otherwise.
func (*PackageIndex) LookupByPlatformName ¶
LookupByPlatformName returns all packages matching the given platform and name, sorted by Version (string ascending). If no packages match, returns nil.
This method never exposes map iteration order; results are always sorted.
func (*PackageIndex) Merge ¶
func (idx *PackageIndex) Merge(pkgs []types.Package)
Merge bulk-adds a slice of packages into the index. Each package is subject to the same dedupe policy as Add.
func (*PackageIndex) Packages ¶
func (idx *PackageIndex) Packages() []types.Package
Packages returns a deterministic sorted projection of all indexed packages. The sort order is ascending by:
- Platform (string)
- Name (string)
- Version (string)
This method never exposes map iteration order; results are always sorted.
type RegistryEdge ¶
type RegistryEdge struct {
TargetNodeID types.RuntimeNodeID
Kind types.RuntimeEdgeVerb
}
type RegistryEntry ¶
type RegistryEntry struct {
NodeID types.RuntimeNodeID
Role types.RuntimeRole
Capabilities []types.RuntimeCapability
RiskLevel types.RuntimeRiskLevel
PolicyEdges []RegistryEdge
}
func FindEntry ¶
func FindEntry(id types.RuntimeNodeID) (RegistryEntry, bool)
type RuntimeRegistry ¶
type RuntimeRegistry struct {
// contains filtered or unexported fields
}
func NewRuntimeRegistry ¶
func NewRuntimeRegistry(entries []RegistryEntry) RuntimeRegistry
func (RuntimeRegistry) FindEntry ¶
func (r RuntimeRegistry) FindEntry(id types.RuntimeNodeID) (RegistryEntry, bool)
type ServerRuntime ¶
type ServerRuntime struct {
PrimaryEntrance string `json:"primary_entrance"`
GameVersion types.BareVersion `json:"game_version"`
BootCommand *exec.Cmd `json:"-"`
Topology *types.RuntimeTopology `json:"topology,omitempty"`
RuntimeIdentities []types.PackageId `json:"runtime_identities,omitempty"`
BridgeHints []string `json:"bridge_hints,omitempty"`
}
func (*ServerRuntime) Analyzable ¶
func (e *ServerRuntime) Analyzable() bool
func (*ServerRuntime) DerivedLoaderVersion ¶
func (e *ServerRuntime) DerivedLoaderVersion() string
func (*ServerRuntime) DerivedModLoader ¶
func (e *ServerRuntime) DerivedModLoader() types.Platform
func (*ServerRuntime) DerivedServerCore ¶
func (e *ServerRuntime) DerivedServerCore() string
func (*ServerRuntime) IsValid ¶
func (e *ServerRuntime) IsValid() bool
func (*ServerRuntime) PrimaryRuntimeIdentity ¶
func (e *ServerRuntime) PrimaryRuntimeIdentity() *types.PackageId
func (*ServerRuntime) RuntimeIdentityPackage ¶
func (e *ServerRuntime) RuntimeIdentityPackage(node *types.TopologyNode) *types.PackageId
type Workspace ¶
type Workspace struct {
Root string `json:"root"` // if found lucy on upperworkspace
SavePath string `json:"save_path"`
ModPath []string `json:"mod_path"`
Packages []types.Package `json:"packages"`
Runtime *ServerRuntime `json:"runtime,omitempty"`
Activity *types.ServerActivity `json:"activity,omitempty"`
Environments types.EnvironmentInfo `json:"environments"`
McdrRoot string `json:"mcdr_root"`
LucyRoot string `json:"lucy_root"`
}
Workspace components that do not exist, use an empty string. Note Runtime must exist, otherwise the program will exit; therefore, it is not a pointer.
func RefreshServerInfo ¶
RefreshServerInfo refreshes probed state for workDir. When workDir matches the current process working directory, this rebuilds the shared cache so future ServerInfo() calls observe the new state. Otherwise it performs an ad hoc reprobe and returns the refreshed observation without mutating the shared cache.
func ServerInfo ¶
func ServerInfo() Workspace
ServerInfo is the exposed function for external packages to get serverInfo. The value is cached after the first build, and read access is blocked while Rebuild refreshes the cache.
func ServerInfoAt ¶
ServerInfoAt probes an explicit working directory without replacing the current process-global ServerInfo cache. This is intended for init-style takeover discovery where the caller may need rich observed state for a target directory that is not the current process working directory.
Source Files
¶
- probe.go
- probe_environment.go
- probe_exec.go
- probe_filelock_unix.go
- probe_interpretation.go
- probe_package_index.go
- probe_runtime_materialize.go
- probe_runtime_types.go
- probe_topology_data.go
- probe_topology_enrich.go
- probe_topology_evaluation.go
- probe_topology_registry.go
- probe_topology_registry_data.go
- probe_workspace_types.go