This commit is contained in:
2025-03-31 09:53:49 +02:00
parent ec73b5ff34
commit 54d31f40b2
8 changed files with 39 additions and 60 deletions

View File

@@ -14,7 +14,6 @@ heroscript:="
masterkey: '1234'
port: 7701
!!meilisearch.start name:'test' reset:1
"
meilisearchinstaller.play(heroscript=heroscript)!

View File

@@ -1,6 +1,6 @@
!!hero_code.generate_installer
name:'qdrant'
name:'qdrant_installer'
classname:'QDrant'
singleton:0
templates:1

View File

@@ -1,9 +1,6 @@
module qdrant
module qdrant_installer
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.osal.zinit
import freeflowuniverse.herolib.installers.ulist
import os

View File

@@ -1,4 +1,4 @@
module qdrant
module qdrant_installer
import freeflowuniverse.herolib.core.base
import freeflowuniverse.herolib.core.playbook
@@ -8,8 +8,8 @@ import freeflowuniverse.herolib.osal.zinit
import time
__global (
qdrant_global map[string]&QDrant
qdrant_default string
qdrant_installer_global map[string]&QDrant
qdrant_installer_default string
)
/////////FACTORY
@@ -32,19 +32,19 @@ pub fn get(args_ ArgsGet) !&QDrant {
mut context := base.context()!
mut args := args_get(args_)
mut obj := QDrant{}
if args.name !in qdrant_global {
if args.name !in qdrant_installer_global {
if !exists(args)! {
set(obj)!
} else {
heroscript := context.hero_config_get('qdrant', args.name)!
heroscript := context.hero_config_get('qdrant_installer', args.name)!
mut obj_ := heroscript_loads(heroscript)!
set_in_mem(obj_)!
}
}
return qdrant_global[args.name] or {
println(qdrant_global)
return qdrant_installer_global[args.name] or {
println(qdrant_installer_global)
// bug if we get here because should be in globals
panic('could not get config for qdrant with name, is bug:${args.name}')
panic('could not get config for qdrant_installer with name, is bug:${args.name}')
}
}
@@ -53,30 +53,30 @@ pub fn set(o QDrant) ! {
set_in_mem(o)!
mut context := base.context()!
heroscript := heroscript_dumps(o)!
context.hero_config_set('qdrant', o.name, heroscript)!
context.hero_config_set('qdrant_installer', o.name, heroscript)!
}
// does the config exists?
pub fn exists(args_ ArgsGet) !bool {
mut context := base.context()!
mut args := args_get(args_)
return context.hero_config_exists('qdrant', args.name)
return context.hero_config_exists('qdrant_installer', args.name)
}
pub fn delete(args_ ArgsGet) ! {
mut args := args_get(args_)
mut context := base.context()!
context.hero_config_delete('qdrant', args.name)!
if args.name in qdrant_global {
// del qdrant_global[args.name]
context.hero_config_delete('qdrant_installer', args.name)!
if args.name in qdrant_installer_global {
// del qdrant_installer_global[args.name]
}
}
// only sets in mem, does not set as config
fn set_in_mem(o QDrant) ! {
mut o2 := obj_init(o)!
qdrant_global[o.name] = &o2
qdrant_default = o.name
qdrant_installer_global[o.name] = &o2
qdrant_installer_default = o.name
}
@[params]
@@ -92,7 +92,7 @@ pub fn play(args_ PlayArgs) ! {
mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
mut install_actions := plbook.find(filter: 'qdrant.configure')!
mut install_actions := plbook.find(filter: 'qdrant_installer.configure')!
if install_actions.len > 0 {
for install_action in install_actions {
heroscript := install_action.heroscript()
@@ -101,37 +101,37 @@ pub fn play(args_ PlayArgs) ! {
}
}
mut other_actions := plbook.find(filter: 'qdrant.')!
mut other_actions := plbook.find(filter: 'qdrant_installer.')!
for other_action in other_actions {
if other_action.name in ['destroy', 'install', 'build'] {
mut p := other_action.params
reset := p.get_default_false('reset')
if other_action.name == 'destroy' || reset {
console.print_debug('install action qdrant.destroy')
console.print_debug('install action qdrant_installer.destroy')
destroy()!
}
if other_action.name == 'install' {
console.print_debug('install action qdrant.install')
console.print_debug('install action qdrant_installer.install')
install()!
}
}
if other_action.name in ['start', 'stop', 'restart'] {
mut p := other_action.params
name := p.get('name')!
mut qdrant_obj := get(name: name)!
console.print_debug('action object:\n${qdrant_obj}')
mut qdrant_installer_obj := get(name: name)!
console.print_debug('action object:\n${qdrant_installer_obj}')
if other_action.name == 'start' {
console.print_debug('install action qdrant.${other_action.name}')
qdrant_obj.start()!
console.print_debug('install action qdrant_installer.${other_action.name}')
qdrant_installer_obj.start()!
}
if other_action.name == 'stop' {
console.print_debug('install action qdrant.${other_action.name}')
qdrant_obj.stop()!
console.print_debug('install action qdrant_installer.${other_action.name}')
qdrant_installer_obj.stop()!
}
if other_action.name == 'restart' {
console.print_debug('install action qdrant.${other_action.name}')
qdrant_obj.restart()!
console.print_debug('install action qdrant_installer.${other_action.name}')
qdrant_installer_obj.restart()!
}
}
}
@@ -175,7 +175,7 @@ pub fn (mut self QDrant) start() ! {
return
}
console.print_header('qdrant start')
console.print_header('qdrant_installer start')
if !installed()! {
install()!
@@ -188,7 +188,7 @@ pub fn (mut self QDrant) start() ! {
for zprocess in startupcmd()! {
mut sm := startupmanager_get(zprocess.startuptype)!
console.print_debug('starting qdrant with ${zprocess.startuptype}...')
console.print_debug('starting qdrant_installer with ${zprocess.startuptype}...')
sm.new(zprocess)!
@@ -203,7 +203,7 @@ pub fn (mut self QDrant) start() ! {
}
time.sleep(100 * time.millisecond)
}
return error('qdrant did not install properly.')
return error('qdrant_installer did not install properly.')
}
pub fn (mut self QDrant) install_start(args InstallArgs) ! {
@@ -266,9 +266,9 @@ pub fn (mut self QDrant) destroy() ! {
destroy()!
}
// switch instance to be used for qdrant
// switch instance to be used for qdrant_installer
pub fn switch(name string) {
qdrant_default = name
qdrant_installer_default = name
}
// helpers

View File

@@ -1,8 +1,8 @@
module qdrant
module qdrant_installer
import os
import freeflowuniverse.herolib.data.encoderhero
import freeflowuniverse.herolib.core.pathlib
import os
pub const version = '1.13.4'
const singleton = false
@@ -35,7 +35,6 @@ fn configure() ! {
mut mycode := $tmpl('templates/config.yaml')
mut path := pathlib.get_file(path: '${os.home_dir()}/hero/var/qdrant/config.yaml', create: true)!
path.write(mycode)!
// console.print_debug(mycode)
}
/////////////NORMALLY NO NEED TO TOUCH

View File

@@ -1,13 +1,12 @@
# qdrant
Is a powerfull db for embedding for AI Agents.
To get started
```vlang
import freeflowuniverse.herolib.installers.something.qdrant as qdrant_installer
import freeflowuniverse.herolib.installers.db.qdrant_installer
heroscript:="
!!qdrant.configure name:'test'
@@ -27,18 +26,3 @@ qdrant_installer.play(heroscript=heroscript)!
```
## example heroscript
```hero
!!qdrant.configure
homedir: '/home/user/qdrant'
username: 'admin'
password: 'secretpassword'
title: 'Some Title'
host: 'localhost'
port: 8888
```