mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 17:14:28 +00:00
Unexport factory functions
This commit is contained in:
@@ -23,8 +23,8 @@ type lifecycleManager struct {
|
|||||||
shutdownOnce sync.Once
|
shutdownOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLifecycleManager creates a new lifecycle manager.
|
// newLifecycleManager creates a new lifecycle manager.
|
||||||
func NewLifecycleManager(
|
func newLifecycleManager(
|
||||||
registry *instanceRegistry,
|
registry *instanceRegistry,
|
||||||
manager InstanceManager,
|
manager InstanceManager,
|
||||||
checkInterval time.Duration,
|
checkInterval time.Duration,
|
||||||
|
|||||||
@@ -52,23 +52,23 @@ func New(backendsConfig config.BackendConfig, instancesConfig config.InstancesCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize components
|
// Initialize components
|
||||||
registry := NewInstanceRegistry()
|
registry := newInstanceRegistry()
|
||||||
|
|
||||||
// Initialize port allocator
|
// Initialize port allocator
|
||||||
portRange := instancesConfig.PortRange
|
portRange := instancesConfig.PortRange
|
||||||
ports, err := NewPortAllocator(portRange[0], portRange[1])
|
ports, err := newPortAllocator(portRange[0], portRange[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to create port allocator: %v", err)
|
log.Fatalf("Failed to create port allocator: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize persistence
|
// Initialize persistence
|
||||||
persistence, err := NewInstancePersister(instancesConfig.InstancesDir)
|
persistence, err := newInstancePersister(instancesConfig.InstancesDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to create instance persister: %v", err)
|
log.Fatalf("Failed to create instance persister: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize remote manager
|
// Initialize remote manager
|
||||||
remote := NewRemoteManager(nodesConfig, 30*time.Second)
|
remote := newRemoteManager(nodesConfig, 30*time.Second)
|
||||||
|
|
||||||
// Create manager instance
|
// Create manager instance
|
||||||
im := &instanceManager{
|
im := &instanceManager{
|
||||||
@@ -83,7 +83,7 @@ func New(backendsConfig config.BackendConfig, instancesConfig config.InstancesCo
|
|||||||
|
|
||||||
// Initialize lifecycle manager (needs reference to manager for Stop/Evict operations)
|
// Initialize lifecycle manager (needs reference to manager for Stop/Evict operations)
|
||||||
checkInterval := time.Duration(instancesConfig.TimeoutCheckInterval) * time.Minute
|
checkInterval := time.Duration(instancesConfig.TimeoutCheckInterval) * time.Minute
|
||||||
im.lifecycle = NewLifecycleManager(registry, im, checkInterval, true)
|
im.lifecycle = newLifecycleManager(registry, im, checkInterval, true)
|
||||||
|
|
||||||
// Load existing instances from disk
|
// Load existing instances from disk
|
||||||
if err := im.loadInstances(); err != nil {
|
if err := im.loadInstances(); err != nil {
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ type instancePersister struct {
|
|||||||
enabled bool
|
enabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInstancePersister creates a new instance persister.
|
// newInstancePersister creates a new instance persister.
|
||||||
// If instancesDir is empty, persistence is disabled.
|
// If instancesDir is empty, persistence is disabled.
|
||||||
func NewInstancePersister(instancesDir string) (*instancePersister, error) {
|
func newInstancePersister(instancesDir string) (*instancePersister, error) {
|
||||||
if instancesDir == "" {
|
if instancesDir == "" {
|
||||||
return &instancePersister{
|
return &instancePersister{
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ type portAllocator struct {
|
|||||||
rangeSize int
|
rangeSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPortAllocator creates a new port allocator for the given port range.
|
// newPortAllocator creates a new port allocator for the given port range.
|
||||||
// Returns an error if the port range is invalid.
|
// Returns an error if the port range is invalid.
|
||||||
func NewPortAllocator(minPort, maxPort int) (*portAllocator, error) {
|
func newPortAllocator(minPort, maxPort int) (*portAllocator, error) {
|
||||||
if minPort <= 0 || maxPort <= 0 {
|
if minPort <= 0 || maxPort <= 0 {
|
||||||
return nil, fmt.Errorf("invalid port range: min=%d, max=%d (must be > 0)", minPort, maxPort)
|
return nil, fmt.Errorf("invalid port range: min=%d, max=%d (must be > 0)", minPort, maxPort)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ type instanceRegistry struct {
|
|||||||
running sync.Map // map[string]struct{} - lock-free for status checks
|
running sync.Map // map[string]struct{} - lock-free for status checks
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInstanceRegistry creates a new instance registry.
|
// newInstanceRegistry creates a new instance registry.
|
||||||
func NewInstanceRegistry() *instanceRegistry {
|
func newInstanceRegistry() *instanceRegistry {
|
||||||
return &instanceRegistry{
|
return &instanceRegistry{
|
||||||
instances: make(map[string]*instance.Instance),
|
instances: make(map[string]*instance.Instance),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ type remoteManager struct {
|
|||||||
instanceToNode map[string]*config.NodeConfig // instance name -> node config
|
instanceToNode map[string]*config.NodeConfig // instance name -> node config
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRemoteManager creates a new remote manager.
|
// newRemoteManager creates a new remote manager.
|
||||||
func NewRemoteManager(nodes map[string]config.NodeConfig, timeout time.Duration) *remoteManager {
|
func newRemoteManager(nodes map[string]config.NodeConfig, timeout time.Duration) *remoteManager {
|
||||||
if timeout <= 0 {
|
if timeout <= 0 {
|
||||||
timeout = 30 * time.Second
|
timeout = 30 * time.Second
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user