mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-11 18:07:33 +00:00
Remove database from Mapper
This commit changes the internals of the mapper to track all the changes to peers over its lifetime. This means that it no longer depends on the database and this should hopefully help with locks and timing issues. When the mapper is created, it needs the current list of peers, the world view, when the polling session was started. Then as update changes are called, it tracks the changes and generates responses based on its internal list. As a side, the types.Machines and types.MachinesP, as well as types.Machine being passed as a full struct and pointer has been changed to always be pointers, everywhere. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:

committed by
Kristoffer Dalby

parent
3b0749a320
commit
387aa03adb
@@ -124,7 +124,7 @@ type StateUpdate struct {
|
||||
|
||||
// Changed must be set when Type is StatePeerChanged and
|
||||
// contain the Machine IDs of machines that has changed.
|
||||
Changed []uint64
|
||||
Changed Machines
|
||||
|
||||
// Removed must be set when Type is StatePeerRemoved and
|
||||
// contain a list of the nodes that has been removed from
|
||||
|
@@ -68,8 +68,7 @@ type Machine struct {
|
||||
}
|
||||
|
||||
type (
|
||||
Machines []Machine
|
||||
MachinesP []*Machine
|
||||
Machines []*Machine
|
||||
)
|
||||
|
||||
type MachineAddresses []netip.Addr
|
||||
@@ -343,19 +342,8 @@ func (machines Machines) String() string {
|
||||
return fmt.Sprintf("[ %s ](%d)", strings.Join(temp, ", "), len(temp))
|
||||
}
|
||||
|
||||
// TODO(kradalby): Remove when we have generics...
|
||||
func (machines MachinesP) String() string {
|
||||
temp := make([]string, len(machines))
|
||||
|
||||
for index, machine := range machines {
|
||||
temp[index] = machine.Hostname
|
||||
}
|
||||
|
||||
return fmt.Sprintf("[ %s ](%d)", strings.Join(temp, ", "), len(temp))
|
||||
}
|
||||
|
||||
func (machines Machines) IDMap() map[uint64]Machine {
|
||||
ret := map[uint64]Machine{}
|
||||
func (machines Machines) IDMap() map[uint64]*Machine {
|
||||
ret := map[uint64]*Machine{}
|
||||
|
||||
for _, machine := range machines {
|
||||
ret[machine.ID] = machine
|
||||
|
Reference in New Issue
Block a user