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

config

package
v1.3.104 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config pkg/serviceconfig/default_environments.go c4-net-discovery

Package config pkg/serviceconfig/env.go c4-net-discovery

Package config pkg/serviceconfig/env_scripts.go c4-net-discovery

Package config pkg/serviceconfig/external_services.go c4-net-discovery

Package config pkg/serviceconfig/runners.go c4-net-discovery

Package config pkg/serviceconfig/skywire.go c4-net-discovery

Package config pkg/serviceconfig/visors.go c4-net-discovery

Index

Examples

Constants

View Source
const (
	// DockerRedisCmdTemplate is a template for running dockerized redis
	DockerRedisCmdTemplate string = `
docker container rm redis -f || \
docker run -d  --network=%v \
		--hostname=redis 	\
		--name=redis  redis`

	// DockerDmsgDiscoveryCmdTemplate is a template for running dockerized dmsg-discovery
	DockerDmsgDiscoveryCmdTemplate string = `` /* 210-byte string literal not displayed */

	// DockerDmsgServerCmdTemplate is a template for running dockerized dmsg-server
	DockerDmsgServerCmdTemplate string = `` /* 187-byte string literal not displayed */

	// DockerTransportDiscoveryCmdTemplate is a template for running dockerized transport-discovery
	DockerTransportDiscoveryCmdTemplate string = `` /* 203-byte string literal not displayed */

	// DockerRouteFinderCmdTemplate is a template for running dockerized route-finder
	DockerRouteFinderCmdTemplate string = `` /* 200-byte string literal not displayed */

	// DockerAddressResolverCmdTemplate is a template for running dockerized address-resolver
	DockerAddressResolverCmdTemplate string = `` /* 209-byte string literal not displayed */

	// DockerSetupNodeCmdTemplate is a template for running dockerized setup-node
	DockerSetupNodeCmdTemplate string = `` /* 182-byte string literal not displayed */

	// DockerSkywireVisorCmdTemplate is a template for running dockerized skywire-visor
	DockerSkywireVisorCmdTemplate string = `` /* 141-byte string literal not displayed */

)
View Source
const (
	// PublicDmsgDiscovery is global dmsg-discovery service
	PublicDmsgDiscovery string = "https://dmsg.discovery.skywire.skycoin.com"
	// PublicTransportDiscovery is  global transport-discovery service
	PublicTransportDiscovery string = "https://transport.discovery.skywire.skycoin.com"
	// PublicRouteFinder is global route finder service
	PublicRouteFinder string = "https://routefinder.skywire.skycoin.com/"
	// PublicSetupNode is public key of global setup-node
	PublicSetupNode string = "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
	// PublicAddressResolver is  global address-resolver service
	PublicAddressResolver string = "https://address.resolver.skywire.skycoin.com"
)

Variables

This section is empty.

Functions

func DefaultPublicVisorConfig

func DefaultPublicVisorConfig() *visorconfig.V1

DefaultPublicVisorConfig constructs skywire-visor config with global skywire-services

func EmptyDmsgServerConfig

func EmptyDmsgServerConfig() msg.Config

EmptyDmsgServerConfig return empty configuration for dmsg-server

func EmptySetupNodeConfig

func EmptySetupNodeConfig() router.SetupConfig

EmptySetupNodeConfig return empty configuration for setup-node

func PrintJSON

func PrintJSON(data interface{}) string

PrintJSON does json-formatting of data

Types

type AddressResolverConfig

type AddressResolverConfig struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
	Cmd     string `json:"cmd,omitempty"`
}

AddressResolverConfig defines configuration of address-resolver

type DmsgDiscoveryConfig

type DmsgDiscoveryConfig struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
	Cmd     string `json:"cmd,omitempty"`
}

DmsgDiscoveryConfig defines configuration of dmsg-discovery

type DmsgServerConfig

type DmsgServerConfig struct {
	Name    string      `json:"name,omitempty"`
	Address string      `json:"address,omitempty"`
	Config  *msg.Config `json:"config,omitempty"`
	Cmd     string      `json:"cmd,omitempty"`
}

DmsgServerConfig defines configuration of dmsg-server

type EnvConfig

type EnvConfig struct {
	Description      string                 `json:"description"`
	Runners          RunnersConfig          `json:"runners"`
	ExternalServices ExternalServicesConfig `json:"external_services,omitempty"`
	Skywire          SkywireConfig          `json:"skywire_services"`
	Visors           []VisorConfig          `json:"skywire"`
	Scripts          EnvScripts             `json:"scripts"`
}

EnvConfig defines configuration of skywire environment

func DefaultDockerizedEnv

func DefaultDockerizedEnv(network string) *EnvConfig

DefaultDockerizedEnv creates environment with dockerized skywire-services and 3 local skywire-visors

func DefaultLocalEnv

func DefaultLocalEnv() *EnvConfig

DefaultLocalEnv creates environment with local skywire-services and 3 local skywire-visors

func DefaultPublicEnv

func DefaultPublicEnv() *EnvConfig

DefaultPublicEnv creates environment with global skywire-services and 3 local skywire-visors

func (*EnvConfig) AddAddressResolver

func (env *EnvConfig) AddAddressResolver(name string, address string) *EnvConfig

AddAddressResolver adds address-resolver configuration to environment configuration

func (*EnvConfig) AddDmsgDiscovery

func (env *EnvConfig) AddDmsgDiscovery(name string, address string) *EnvConfig

AddDmsgDiscovery adds dmsg-discovery configuration to environment configuration

func (*EnvConfig) AddDmsgServer

func (env *EnvConfig) AddDmsgServer(name string, publicAddress string, localAddress string) *EnvConfig

AddDmsgServer adds dmsg-server configuration to environment configuration

func (*EnvConfig) AddRouteFinder

func (env *EnvConfig) AddRouteFinder(name string, address string) *EnvConfig

AddRouteFinder adds route-finder configuration to environment configuration

func (*EnvConfig) AddSetupNode

func (env *EnvConfig) AddSetupNode(name string) *EnvConfig

AddSetupNode adds setup-node configuration to environment configuration

func (*EnvConfig) AddThreeChatVisors

func (env *EnvConfig) AddThreeChatVisors() *EnvConfig

AddThreeChatVisors add to environment 3 visors: VisorA an VisorC running skychat application and VisorB to be used as intermediary between them

Example
globalEnv := &EnvConfig{
	Description: "Example of environment configuration with global skywire-services and 3 skywire-visors",
	Runners: RunnersConfig{
		SkywireVisor: "skywire-visor {{.Name}}.json",
	},
	Skywire: DefaultPublicSkywire(),
}

env := globalEnv.AddThreeChatVisors()

fmt.Printf("VisorA skychat args: %v\n", env.Visors[0].Config.Launcher.Apps[0].Args)
fmt.Printf("VisorB apps: %v\n", env.Visors[1].Config.Launcher.Apps)
fmt.Printf("VisorC skychat args: %v\n", env.Visors[2].Config.Launcher.Apps[0].Args)
Output:
VisorA skychat args: [-addr :8002]
VisorB apps: []
VisorC skychat args: [-addr :8003]

func (*EnvConfig) AddTransportDiscovery

func (env *EnvConfig) AddTransportDiscovery(name string, address string) *EnvConfig

AddTransportDiscovery adds transport-discovery configuration to environment configuration

func (*EnvConfig) AddVisor

func (env *EnvConfig) AddVisor(visorName string, apps []appserver.AppConfig, rpcAddress string) *EnvConfig

AddVisor adds a skywire node configuration

Example
publicEnv := &EnvConfig{
	Description: "Example of environment configuration with global skywire-services and 3 skywire-visors",
	Runners: RunnersConfig{
		SkywireVisor: "go run ./cmd/skywire-visor {{.Name}}.json --tag {{.Name}}",
	},
	Skywire: DefaultPublicSkywire(),
}

appsA := []appserver.AppConfig{
	{Name: "skychat", Port: 1, AutoStart: true, Args: []string{"-addr", ":8002"}},
}
appsB := make([]appserver.AppConfig, 0)
appsC := []appserver.AppConfig{
	{Name: "skychat", Port: 1, AutoStart: true, Args: []string{"-addr", ":8003"}},
}

env := publicEnv.
	AddVisor("VisorA", appsA, ":3435").
	AddVisor("VisorB", appsB, ":3436").
	AddVisor("VisorC", appsC, ":3437")

for n, visor := range env.Visors {
	fmt.Printf("%v %v: %v\n", n, visor.Name, visor.Cmd)
}
Output:
0 VisorA: go run ./cmd/skywire-visor VisorA.json --tag VisorA
1 VisorB: go run ./cmd/skywire-visor VisorB.json --tag VisorB
2 VisorC: go run ./cmd/skywire-visor VisorC.json --tag VisorC

func (*EnvConfig) AddVisorExplicitly

func (env *EnvConfig) AddVisorExplicitly(visor VisorConfig) *EnvConfig

AddVisorExplicitly adds an explicit skywire node configuration to environment configuration

Example
env := &EnvConfig{
	Description:      "Example of minimal environment with global skywire-services and single skywire-visor",
	ExternalServices: ExternalServicesConfig{},
	Runners: RunnersConfig{
		SkywireVisor: "skywire-visor",
	},
	Skywire: DefaultPublicSkywire(),
}
env.AddVisorExplicitly(VisorConfig{
	Name:   "VisorA",
	Config: DefaultPublicVisorConfig(),
	Cmd:    "skywire-visor VisorA.json",
})

fmt.Printf("Visor: %v\n", env.Visors[0].Cmd)
Output:
Visor: skywire-visor VisorA.json

func (*EnvConfig) DefaultExternalServices

func (env *EnvConfig) DefaultExternalServices() *EnvConfig

DefaultExternalServices returns default externalServices configuration for localhost environments

func (*EnvConfig) String

func (env *EnvConfig) String() string

type EnvScripts

type EnvScripts struct {
	Startup  string `json:"startup,omitempty"`
	TearDown string `json:"teardown,omitempty"`
	EnvVars  string `json:"env_vars,omitempty"`
}

EnvScripts is a collection of environment scripts

func (EnvScripts) String

func (scr EnvScripts) String() string

type ExternalServicesConfig

type ExternalServicesConfig struct {
	RedisAddress   string `json:"redis,omitempty"`
	RedisCmd       string `json:"redis_cmd,omitempty"`
	MetricsAddress string `json:"metrics,omitempty"`
}

ExternalServicesConfig define configuration of external services

func (ExternalServicesConfig) String

func (ext ExternalServicesConfig) String() string

type RouteFinderConfig

type RouteFinderConfig struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
	Cmd     string `json:"cmd,omitempty"`
}

RouteFinderConfig defines configuration of route-finder

type RunnersConfig

type RunnersConfig struct {
	SkywireVisor       string `json:"skywire,omitempty"`
	DmsgDiscovery      string `json:"dmsg_discovery,omitempty"`
	DmsgServer         string `json:"dmsg_server,omitempty"`
	TransportDiscovery string `json:"transport_discovery,omitempty"`
	RouteFinder        string `json:"route_finder,omitempty"`
	SetupNode          string `json:"setup_node,omitempty"`
	AddressResolver    string `json:"address_resolver,omitempty"`
}

RunnersConfig defines how each service is run

func DefaultDockerRunners

func DefaultDockerRunners(network string) RunnersConfig

DefaultDockerRunners returns set of default dockerized runners

Example
dockerEnv := &EnvConfig{
	Description: "Example of environment configuration with dockerized skywire",
	ExternalServices: ExternalServicesConfig{
		RedisAddress: "redis:6379",
	},
	Runners: DefaultDockerRunners("SKYNET_001"),
}

env := dockerEnv.
	AddDmsgDiscovery("MSGD", "dmsg-discovery:9090").
	AddDmsgServer("MSG", "dmsg-server:8080", "dmsg-server:8080").
	AddTransportDiscovery("TRD", "transport-discovery:9094").
	AddRouteFinder("RF", "route-finder:9092").
	AddSetupNode("SN").
	AddAddressResolver("AR", "address-resolver:9093")

fmt.Println(env.Description)

fmt.Println(env.Skywire.DmsgDiscovery.Cmd)
fmt.Println(env.Skywire.DmsgServer.Cmd)
fmt.Println(env.Skywire.TransportDiscovery.Cmd)
fmt.Println(env.Skywire.RouteFinder.Cmd)
fmt.Println(env.Skywire.AddressResolver.Cmd)
fmt.Println(env.Skywire.SetupNode.Cmd)
Output:
Example of environment configuration with dockerized skywire

docker container rm dmsg-discovery -f || \
docker run -d --network=SKYNET_001  	\
				--name=dmsg-discovery	\
				--hostname=dmsg-discovery	skywire-services  \
				bash -c "./dmsg-discovery --redis redis://redis:6379"

docker container rm dmsg-server -f || \
docker run -d --network=SKYNET_001  	\
				--name=dmsg-server	\
				--hostname=dmsg-server	skywire-services \
				bash -c "./dmsg-server dmsg-server.json"

docker container rm transport-discovery -f || \
docker run -d --network=SKYNET_001  	\
				--name=transport-discovery	\
				--hostname=transport-discovery	skywire-services \
					bash -c "./transport-discovery"

docker container rm dmsg-server -f || \
docker run -d --network=SKYNET_001  	\
				--name=dmsg-server	\
				--hostname=dmsg-server	skywire-services \
				bash -c "./dmsg-server dmsg-server.json"

docker container rm address-resolver -f || \
docker run -d --network=SKYNET_001\
				--name=address-resolver	\
				--hostname=address-resolver	skywire-services \
				bash -c "./address-resolver address-resolver.json"

docker container rm setup-node -f || \
docker run -d --network=SKYNET_001\
					--name=setup-node	\
					--hostname=setup-node	skywire-services \
					bash -c "./setup-node setup-node.json"

func DefaultLocalRunners

func DefaultLocalRunners() RunnersConfig

DefaultLocalRunners returns set of default runners on localhost

type SetupNodeConfig

type SetupNodeConfig struct {
	Name   string              `json:"name,omitempty"`
	PubKey cipher.PubKey       `json:"pk,omitempty"`
	Config *router.SetupConfig `json:"config,omitempty"`
	Cmd    string              `json:"cmd,omitempty"`
}

SetupNodeConfig defines configuration of setup-node

type SkywireConfig

type SkywireConfig struct {
	DmsgDiscovery      DmsgDiscoveryConfig      `json:"dmsg_discovery,omitempty"`
	DmsgServer         DmsgServerConfig         `json:"dmsg_server,omitempty"`
	TransportDiscovery TransportDiscoveryConfig `json:"transport_discovery,omitempty"`
	RouteFinder        RouteFinderConfig        `json:"route_finder,omitempty"`
	SetupNode          SetupNodeConfig          `json:"setup_node,omitempty"`
	AddressResolver    AddressResolverConfig    `json:"address_resolver,omitempty"`
}

SkywireConfig defines configuration of skywire-services

func DefaultPublicSkywire

func DefaultPublicSkywire() SkywireConfig

DefaultPublicSkywire constructs default global skywire-services configuration

Example

ExampleEnvConfig is an example of explicit declaration of minimal configuration with global skywire-services and just one skywire-visor and no startup/teardown scripts

env := EnvConfig{
	Description:      "Example of minimal environment with global skywire-services and single skywire-visor",
	ExternalServices: ExternalServicesConfig{},
	Runners: RunnersConfig{
		SkywireVisor: "skywire-visor",
	},
	Skywire: DefaultPublicSkywire(),
	Visors: []VisorConfig{
		{
			Name:   "VisorA.json",
			Config: DefaultPublicVisorConfig(),
			Cmd:    "skywire-visor VisorA.json",
		},
	},
	Scripts: EnvScripts{},
}
fmt.Println(env.Description)
fmt.Printf("external services: %v\n", env.ExternalServices)
fmt.Printf("running skywire-visor with: %v\n", env.Runners.SkywireVisor)
fmt.Printf("with skywire-services: %v\n", env.Skywire)
fmt.Printf("with skywire visors: %v\n", env.Visors[0].Cmd)
fmt.Printf("with scripts: %v\n", env.Scripts)
Output:
Example of minimal environment with global skywire-services and single skywire-visor
external services: {}
running skywire-visor with: skywire-visor
with skywire-services: {
	"dmsg_discovery": {
		"address": "https://dmsg.discovery.skywire.skycoin.com"
	},
	"dmsg_server": {},
	"transport_discovery": {
		"address": "https://transport.discovery.skywire.skycoin.com"
	},
	"route_finder": {
		"address": "https://routefinder.skywire.skycoin.com/"
	},
	"setup_node": {
		"pk": "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
	},
	"address_resolver": {
		"address": "https://address.resolver.skywire.skycoin.com"
	}
}
with skywire visors: skywire-visor VisorA.json
with scripts: {}

func (SkywireConfig) String

func (sw SkywireConfig) String() string

type TransportDiscoveryConfig

type TransportDiscoveryConfig struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
	Cmd     string `json:"cmd,omitempty"`
}

TransportDiscoveryConfig defines configuration of transport-discovery

type VisorConfig

type VisorConfig struct {
	Name   string          `json:"name"`
	Config *visorconfig.V1 `json:"config"`
	Cmd    string          `json:"cmd"`
}

VisorConfig defines skywire-visor configuration

func (VisorConfig) String

func (visorConfig VisorConfig) String() string

Jump to

Keyboard shortcuts

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