mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 09:04:27 +00:00
Delete unused code
This commit is contained in:
@@ -26,18 +26,6 @@ type InstanceManager interface {
|
|||||||
Shutdown()
|
Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoteManager interface {
|
|
||||||
ListRemoteInstances(node *config.NodeConfig) ([]*instance.Instance, error)
|
|
||||||
CreateRemoteInstance(node *config.NodeConfig, name string, options *instance.Options) (*instance.Instance, error)
|
|
||||||
GetRemoteInstance(node *config.NodeConfig, name string) (*instance.Instance, error)
|
|
||||||
UpdateRemoteInstance(node *config.NodeConfig, name string, options *instance.Options) (*instance.Instance, error)
|
|
||||||
DeleteRemoteInstance(node *config.NodeConfig, name string) error
|
|
||||||
StartRemoteInstance(node *config.NodeConfig, name string) (*instance.Instance, error)
|
|
||||||
StopRemoteInstance(node *config.NodeConfig, name string) (*instance.Instance, error)
|
|
||||||
RestartRemoteInstance(node *config.NodeConfig, name string) (*instance.Instance, error)
|
|
||||||
GetRemoteInstanceLogs(node *config.NodeConfig, name string, numLines int) (string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type instanceManager struct {
|
type instanceManager struct {
|
||||||
// Components (each with own synchronization)
|
// Components (each with own synchronization)
|
||||||
registry *instanceRegistry
|
registry *instanceRegistry
|
||||||
|
|||||||
@@ -100,32 +100,6 @@ func (p *instancePersister) save(inst *instance.Instance) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads a single instance from disk by name.
|
|
||||||
func (p *instancePersister) load(name string) (*instance.Instance, error) {
|
|
||||||
if !p.enabled {
|
|
||||||
return nil, fmt.Errorf("persistence is disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.validateInstanceName(name); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
p.mu.Lock()
|
|
||||||
defer p.mu.Unlock()
|
|
||||||
|
|
||||||
instancePath := filepath.Join(p.instancesDir, name+".json")
|
|
||||||
|
|
||||||
inst, err := p.loadInstanceFile(name, instancePath)
|
|
||||||
if err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return nil, fmt.Errorf("instance %s not found", name)
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return inst, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete removes an instance's persistence file from disk.
|
// Delete removes an instance's persistence file from disk.
|
||||||
func (p *instancePersister) delete(name string) error {
|
func (p *instancePersister) delete(name string) error {
|
||||||
if !p.enabled {
|
if !p.enabled {
|
||||||
|
|||||||
@@ -119,13 +119,3 @@ func (r *instanceRegistry) count() int {
|
|||||||
defer r.mu.RUnlock()
|
defer r.mu.RUnlock()
|
||||||
return len(r.instances)
|
return len(r.instances)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountRunning returns the number of currently running instances.
|
|
||||||
func (r *instanceRegistry) countRunning() int {
|
|
||||||
count := 0
|
|
||||||
r.running.Range(func(key, value any) bool {
|
|
||||||
count++
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -137,21 +137,6 @@ func parseRemoteResponse(resp *http.Response, result any) error {
|
|||||||
|
|
||||||
// --- Remote CRUD operations ---
|
// --- Remote CRUD operations ---
|
||||||
|
|
||||||
// ListInstances lists all instances on a remote node.
|
|
||||||
func (rm *remoteManager) listInstances(ctx context.Context, node *config.NodeConfig) ([]*instance.Instance, error) {
|
|
||||||
resp, err := rm.makeRemoteRequest(ctx, node, "GET", apiBasePath, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var instances []*instance.Instance
|
|
||||||
if err := parseRemoteResponse(resp, &instances); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return instances, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateInstance creates a new instance on a remote node.
|
// CreateInstance creates a new instance on a remote node.
|
||||||
func (rm *remoteManager) createInstance(ctx context.Context, node *config.NodeConfig, name string, opts *instance.Options) (*instance.Instance, error) {
|
func (rm *remoteManager) createInstance(ctx context.Context, node *config.NodeConfig, name string, opts *instance.Options) (*instance.Instance, error) {
|
||||||
path := fmt.Sprintf("%s%s/", apiBasePath, name)
|
path := fmt.Sprintf("%s%s/", apiBasePath, name)
|
||||||
|
|||||||
Reference in New Issue
Block a user