Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update service discovery references #872

Merged
merged 8 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed Char
Empty file.
6 changes: 3 additions & 3 deletions cmd/skywire-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ $ skywire-cli visor gen-config
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down Expand Up @@ -512,7 +512,7 @@ $ skywire-cli visor gen-config -ip
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down Expand Up @@ -886,7 +886,7 @@ skywire-cli visor update-config
"launcher": {
"discovery": {
"update_interval": "30s",
"proxy_discovery_addr": "http://service.discovery.skycoin.com"
"service_discovery": "http://service.discovery.skycoin.com"
},
"apps": [
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/appdisc/const.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package appdisc

// ChangeValue keys. Each key changes a different value for proxyUpdater.ChangeValue
// ChangeValue keys. Each key changes a different value for serviceUpdater.ChangeValue
const (
// ConnCountValue represents the number of remote connections to a given proc.
ConnCountValue = "conn_count"
Expand Down
14 changes: 7 additions & 7 deletions pkg/app/appdisc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ type Factory struct {
PK cipher.PubKey
SK cipher.SecKey
UpdateInterval time.Duration
ProxyDisc string // Address of proxy-discovery
ServiceDisc string // Address of service-discovery
}

func (f *Factory) setDefaults() {
if f.Log == nil {
f.Log = logging.MustGetLogger("appdisc")
}
if f.UpdateInterval == 0 {
f.UpdateInterval = skyenv.AppDiscUpdateInterval
f.UpdateInterval = skyenv.ServiceDiscUpdateInterval
}
if f.ProxyDisc == "" {
f.ProxyDisc = skyenv.DefaultServiceDiscAddr
if f.ServiceDisc == "" {
f.ServiceDisc = skyenv.DefaultServiceDiscAddr
}
}

Expand All @@ -45,7 +45,7 @@ func (f *Factory) VisorUpdater(port uint16) Updater {
PK: f.PK,
SK: f.SK,
Port: port,
DiscAddr: f.ProxyDisc,
DiscAddr: f.ServiceDisc,
}

return &serviceUpdater{
Expand All @@ -63,7 +63,7 @@ func (f *Factory) AppUpdater(conf appcommon.ProcConfig) (Updater, bool) {

log := f.Log.WithField("appName", conf.AppName)

// Do not update in proxy discovery if passcode-protected.
// Do not update in service discovery if passcode-protected.
if conf.ContainsFlag("passcode") && conf.ArgVal("passcode") != "" {
return &emptyUpdater{}, false
}
Expand All @@ -74,7 +74,7 @@ func (f *Factory) AppUpdater(conf appcommon.ProcConfig) (Updater, bool) {
PK: f.PK,
SK: f.SK,
Port: uint16(conf.RoutingPort),
DiscAddr: f.ProxyDisc,
DiscAddr: f.ServiceDisc,
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/skyenv/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ const (

// Default skywire app server and discovery constants
const (
DefaultAppSrvAddr = "localhost:5505"
AppDiscUpdateInterval = time.Minute
DefaultAppBinPath = DefaultSkywirePath + "/apps"
DefaultLogLevel = "info"
DefaultAppSrvAddr = "localhost:5505"
ServiceDiscUpdateInterval = time.Minute
DefaultAppBinPath = DefaultSkywirePath + "/apps"
DefaultLogLevel = "info"
)

// Package defaults
Expand Down
10 changes: 5 additions & 5 deletions pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func initDiscovery(ctx context.Context, v *Visor, log *logging.Logger) error {
factory.PK = v.conf.PK
factory.SK = v.conf.SK
factory.UpdateInterval = time.Duration(conf.Discovery.UpdateInterval)
factory.ProxyDisc = conf.Discovery.ServiceDisc
factory.ServiceDisc = conf.Discovery.ServiceDisc
}
v.initLock.Lock()
v.serviceDisc = factory
Expand Down Expand Up @@ -652,9 +652,9 @@ func initPublicVisors(ctx context.Context, v *Visor, log *logging.Logger) error
if !v.conf.Transport.AutoconnectPublic {
return nil
}
proxyDisc := v.conf.Launcher.Discovery.ServiceDisc
if proxyDisc == "" {
proxyDisc = skyenv.DefaultServiceDiscAddr
serviceDisc := v.conf.Launcher.Discovery.ServiceDisc
if serviceDisc == "" {
serviceDisc = skyenv.DefaultServiceDiscAddr
}

// todo: refactor appdisc: split connecting to services in appdisc and
Expand All @@ -666,7 +666,7 @@ func initPublicVisors(ctx context.Context, v *Visor, log *logging.Logger) error
PK: v.conf.PK,
SK: v.conf.SK,
Port: uint16(0),
DiscAddr: proxyDisc,
DiscAddr: serviceDisc,
}
connector := servicedisc.MakeConnector(conf, 5, v.tpM, log)
go connector.Run(ctx) //nolint:errcheck
Expand Down
2 changes: 1 addition & 1 deletion pkg/visor/visorconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# V1AppDisc

- `update_interval` (Duration)
- `proxy_discovery_addr` (string)
- `service_discovery` (string)


# V1LogStore
Expand Down
10 changes: 5 additions & 5 deletions pkg/visor/visorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func MakeBaseConfig(common *Common) *V1 {
RouteFinderTimeout: DefaultTimeout,
}
conf.Launcher = &V1Launcher{
Discovery: &V1AppDisc{
Discovery: &V1Disc{
ServiceDisc: skyenv.DefaultServiceDiscAddr,
},
Apps: nil,
Expand Down Expand Up @@ -89,8 +89,8 @@ func defaultConfigFromCommon(cc *Common, hypervisor bool) (*V1, error) {
Addr: skyenv.DefaultUptimeTrackerAddr,
}

conf.Launcher.Discovery = &V1AppDisc{
UpdateInterval: Duration(skyenv.AppDiscUpdateInterval),
conf.Launcher.Discovery = &V1Disc{
UpdateInterval: Duration(skyenv.ServiceDiscUpdateInterval),
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}

Expand Down Expand Up @@ -218,8 +218,8 @@ func SetDefaultProductionValues(conf *V1) {
conf.UptimeTracker = &V1UptimeTracker{
Addr: skyenv.DefaultUptimeTrackerAddr,
}
conf.Launcher.Discovery = &V1AppDisc{
UpdateInterval: Duration(skyenv.AppDiscUpdateInterval),
conf.Launcher.Discovery = &V1Disc{
UpdateInterval: Duration(skyenv.ServiceDiscUpdateInterval),
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}
}
2 changes: 1 addition & 1 deletion pkg/visor/visorconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func parseV0(cc *Common, raw []byte) (*V1, error) {

func ensureAppDisc(conf *V1) *V1 {
if conf.Launcher.Discovery == nil {
conf.Launcher.Discovery = &V1AppDisc{
conf.Launcher.Discovery = &V1Disc{
ServiceDisc: skyenv.DefaultServiceDiscAddr,
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/visor/visorconfig/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ type V1UptimeTracker struct {
Addr string `json:"addr"`
}

// V1AppDisc configures Skywire App Discovery Clients.
type V1AppDisc struct {
// V1Disc configures Skywire App Discovery Clients.
type V1Disc struct {
ersonp marked this conversation as resolved.
Show resolved Hide resolved
UpdateInterval Duration `json:"update_interval,omitempty"`
ServiceDisc string `json:"proxy_discovery_addr"` // TODO: change JSON name
ServiceDisc string `json:"service_discovery"`
}

// V1Launcher configures the app launcher.
type V1Launcher struct {
Discovery *V1AppDisc `json:"discovery"`
Discovery *V1Disc `json:"discovery"`
Apps []launcher.AppConfig `json:"apps"`
ServerAddr string `json:"server_addr"`
BinPath string `json:"bin_path"`
Expand Down