mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 14:35:00 +00:00
feat(federation): do not allocate local services for load balancing (#3337)
* refactor: extract proxy into functions * feat(federation): do not allocate services, directly connect with libp2p Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
bcd3c1deb2
commit
6d350ccce0
4 changed files with 96 additions and 109 deletions
|
@ -14,6 +14,7 @@ type NodeData struct {
|
|||
Name string
|
||||
ID string
|
||||
TunnelAddress string
|
||||
ServiceID string
|
||||
LastSeen time.Time
|
||||
}
|
||||
|
||||
|
@ -39,6 +40,19 @@ func GetAvailableNodes(serviceID string) []NodeData {
|
|||
return availableNodes
|
||||
}
|
||||
|
||||
func GetNode(serviceID, nodeID string) (NodeData, bool) {
|
||||
if serviceID == "" {
|
||||
serviceID = defaultServicesID
|
||||
}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if _, ok := nodes[serviceID]; !ok {
|
||||
return NodeData{}, false
|
||||
}
|
||||
nd, exists := nodes[serviceID][nodeID]
|
||||
return nd, exists
|
||||
}
|
||||
|
||||
func AddNode(serviceID string, node NodeData) {
|
||||
if serviceID == "" {
|
||||
serviceID = defaultServicesID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue