refactor: move http api to a new transport layer
This commit is contained in:
parent
476c4b056f
commit
0448f66ab2
41 changed files with 822 additions and 390 deletions
|
|
@ -14,5 +14,8 @@ var DefaultConfig = Config{
|
|||
BackoffCount: 4,
|
||||
NodeTimeout: 120,
|
||||
},
|
||||
Host: HostConfig{
|
||||
ListenAddress: "0.0.0.0:56715",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ type HostConfig struct {
|
|||
LocalAddress string `toml:"local_address"`
|
||||
InternalEntrypoint string `toml:"internal_entrypoint"`
|
||||
ExternalEntrypoint string `toml:"external_entrypoint"`
|
||||
ListenAddress string `toml:"listen_address"`
|
||||
baseRoleConfig
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +41,10 @@ func (c HostConfig) Validate() error {
|
|||
return errors.New("missing external entrypoint")
|
||||
}
|
||||
|
||||
if c.ListenAddress == "" {
|
||||
return errors.New("missing listen address")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -67,4 +72,8 @@ func (c *HostConfig) Merge(other HostConfig) {
|
|||
if other.ExternalEntrypoint != "" {
|
||||
c.ExternalEntrypoint = other.ExternalEntrypoint
|
||||
}
|
||||
|
||||
if other.ListenAddress != "" {
|
||||
c.ListenAddress = other.ListenAddress
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,12 @@ func (c NodeConfig) Validate() error {
|
|||
return errors.New("invalid keepalive_interval")
|
||||
}
|
||||
|
||||
if c.ListenOn == "" {
|
||||
return errors.New("missing listen_on")
|
||||
}
|
||||
|
||||
if net.ParseIP(c.ListenOn) == nil {
|
||||
return errors.New("invalid listen_on")
|
||||
return fmt.Errorf("invalid listen_on: %v", c.ListenOn)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue