mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Unexport factory functions
This commit is contained in:
@@ -23,8 +23,8 @@ type lifecycleManager struct {
|
||||
shutdownOnce sync.Once
|
||||
}
|
||||
|
||||
// NewLifecycleManager creates a new lifecycle manager.
|
||||
func NewLifecycleManager(
|
||||
// newLifecycleManager creates a new lifecycle manager.
|
||||
func newLifecycleManager(
|
||||
registry *instanceRegistry,
|
||||
manager InstanceManager,
|
||||
checkInterval time.Duration,
|
||||
|
||||
@@ -52,23 +52,23 @@ func New(backendsConfig config.BackendConfig, instancesConfig config.InstancesCo
|
||||
}
|
||||
|
||||
// Initialize components
|
||||
registry := NewInstanceRegistry()
|
||||
registry := newInstanceRegistry()
|
||||
|
||||
// Initialize port allocator
|
||||
portRange := instancesConfig.PortRange
|
||||
ports, err := NewPortAllocator(portRange[0], portRange[1])
|
||||
ports, err := newPortAllocator(portRange[0], portRange[1])
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create port allocator: %v", err)
|
||||
}
|
||||
|
||||
// Initialize persistence
|
||||
persistence, err := NewInstancePersister(instancesConfig.InstancesDir)
|
||||
persistence, err := newInstancePersister(instancesConfig.InstancesDir)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create instance persister: %v", err)
|
||||
}
|
||||
|
||||
// Initialize remote manager
|
||||
remote := NewRemoteManager(nodesConfig, 30*time.Second)
|
||||
remote := newRemoteManager(nodesConfig, 30*time.Second)
|
||||
|
||||
// Create manager instance
|
||||
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)
|
||||
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
|
||||
if err := im.loadInstances(); err != nil {
|
||||
|
||||
@@ -18,9 +18,9 @@ type instancePersister struct {
|
||||
enabled bool
|
||||
}
|
||||
|
||||
// NewInstancePersister creates a new instance persister.
|
||||
// newInstancePersister creates a new instance persister.
|
||||
// If instancesDir is empty, persistence is disabled.
|
||||
func NewInstancePersister(instancesDir string) (*instancePersister, error) {
|
||||
func newInstancePersister(instancesDir string) (*instancePersister, error) {
|
||||
if instancesDir == "" {
|
||||
return &instancePersister{
|
||||
enabled: false,
|
||||
|
||||
@@ -23,9 +23,9 @@ type portAllocator struct {
|
||||
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.
|
||||
func NewPortAllocator(minPort, maxPort int) (*portAllocator, error) {
|
||||
func newPortAllocator(minPort, maxPort int) (*portAllocator, error) {
|
||||
if minPort <= 0 || maxPort <= 0 {
|
||||
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
|
||||
}
|
||||
|
||||
// NewInstanceRegistry creates a new instance registry.
|
||||
func NewInstanceRegistry() *instanceRegistry {
|
||||
// newInstanceRegistry creates a new instance registry.
|
||||
func newInstanceRegistry() *instanceRegistry {
|
||||
return &instanceRegistry{
|
||||
instances: make(map[string]*instance.Instance),
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ type remoteManager struct {
|
||||
instanceToNode map[string]*config.NodeConfig // instance name -> node config
|
||||
}
|
||||
|
||||
// NewRemoteManager creates a new remote manager.
|
||||
func NewRemoteManager(nodes map[string]config.NodeConfig, timeout time.Duration) *remoteManager {
|
||||
// newRemoteManager creates a new remote manager.
|
||||
func newRemoteManager(nodes map[string]config.NodeConfig, timeout time.Duration) *remoteManager {
|
||||
if timeout <= 0 {
|
||||
timeout = 30 * time.Second
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user