mirror of
https://github.com/hanzoai/base.git
synced 2026-10-21 03:41:50 +00:00
Every non-handler call site that wrapped a value in slog.String/Int/Bool/Any/Float64/Uint64 was passing an Attr through the variadic any... slot of (*slog.Logger).Info/Warn/Error/Debug; the same slot accepts the bare "key", value pair with identical semantics. Drop the wrapper so the surface is one level less indirect and so the next two commits can swap (*slog.Logger) for a small Logger interface without rewriting every attr expression as well. 23 files, 156 call sites collapsed; no behavior change. Five files — tools/logger/log.go, tools/logger/batch_handler.go +_test, and core/log_printer.go +_test — are the handler-implementation layer and legitimately reference slog.Attr/Level/Group; they were skipped.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package functions
|
|
|
|
import (
|
|
"github.com/hanzoai/base/core"
|
|
)
|
|
|
|
const collectionFunctions = "_functions"
|
|
|
|
func (p *plugin) ensureCollections() error {
|
|
_, err := p.app.FindCollectionByNameOrId(collectionFunctions)
|
|
if err == nil {
|
|
return nil // already exists
|
|
}
|
|
|
|
c := core.NewBaseCollection(collectionFunctions)
|
|
c.System = true
|
|
c.Fields.Add(
|
|
&core.TextField{Name: "name", Required: true, Max: 255},
|
|
&core.TextField{Name: "qualifiedName", Required: true, Max: 512},
|
|
&core.TextField{Name: "tenantId", Required: true, Max: 255},
|
|
&core.TextField{Name: "image", Max: 1024},
|
|
&core.TextField{Name: "runtime", Max: 64},
|
|
&core.TextField{Name: "handler", Max: 512},
|
|
&core.SelectField{
|
|
Name: "status",
|
|
Required: true,
|
|
MaxSelect: 1,
|
|
Values: []string{"deployed", "building", "error", "deleted"},
|
|
},
|
|
&core.JSONField{Name: "envVars"},
|
|
&core.JSONField{Name: "metadata"},
|
|
&core.AutodateField{Name: "created", OnCreate: true},
|
|
&core.AutodateField{Name: "updated", OnCreate: true, OnUpdate: true},
|
|
)
|
|
|
|
p.app.Logger().Info("creating functions system collection", "name", collectionFunctions)
|
|
return p.app.Save(c)
|
|
}
|