chore: unify naming for node related types
This commit is contained in:
parent
bbee40ec98
commit
4d44012d06
12 changed files with 72 additions and 53 deletions
|
|
@ -16,11 +16,11 @@ import (
|
|||
)
|
||||
|
||||
type Role struct {
|
||||
state *state.RuntimeState
|
||||
config config.HostConfig
|
||||
state *state.RuntimeState
|
||||
config config.HostConfig
|
||||
|
||||
client *traefikClient
|
||||
tasksGroup sync.WaitGroup
|
||||
client *traefikClient
|
||||
tasksGroup sync.WaitGroup
|
||||
|
||||
externalDomains []string // TODO: i don't like hardcoding external/internal logic here
|
||||
internalDomains []string
|
||||
|
|
@ -37,15 +37,15 @@ func New(state *state.RuntimeState, config config.HostConfig) *Role {
|
|||
func (r *Role) sendUpdate(domains []string, role types.Role) {
|
||||
state := types.HostState{
|
||||
Domains: domains,
|
||||
Name: r.state.Self.Name,
|
||||
Endpoint: r.state.Self.Address,
|
||||
Hostname: r.state.Self.Hostname,
|
||||
Address: r.state.Self.Endpoint,
|
||||
}
|
||||
|
||||
for _, node := range r.state.Registry.ByRole(role) {
|
||||
r.tasksGroup.Go(func() {
|
||||
logger := log.With().Str("name", node.Name).Logger()
|
||||
logger := log.With().Str("name", node.Hostname).Logger()
|
||||
logger.Debug().Msg("sending update")
|
||||
if _, err := client.Post[any](node.Address, types.PathDnsCallback, state); err != nil {
|
||||
if _, err := client.Post[any](node.Endpoint, types.PathDnsCallback, state); err != nil {
|
||||
logger.Warn().Err(err).Msg("unable to send dns info")
|
||||
} else {
|
||||
logger.Debug().Msg("update sent")
|
||||
|
|
@ -87,8 +87,8 @@ func (r *Role) onCallback(w http.ResponseWriter, req *http.Request) {
|
|||
func (r *Role) getInternal() (types.HostState, error) {
|
||||
return types.HostState{
|
||||
Domains: r.internalDomains,
|
||||
Endpoint: r.config.IpAddress,
|
||||
Name: r.state.Self.Name,
|
||||
Address: r.config.IpAddress,
|
||||
Hostname: r.state.Self.Hostname,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue