app

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package app is the public entry point for downstream projects that want to embed wick as a library. A typical main looks like:

package main

import "github.com/yogasw/wick/app"

func main() {
    app.RegisterTool(toolMeta, toolCfg, mytool.Register)
    app.RegisterJob(jobMeta, jobCfg, myjob.Run)
    app.Run()
}

Navbar, admin, auth, rendering, and the cron scheduler are handled by wick; downstream only supplies per-instance meta, a typed config value, and a RegisterFunc / RunFunc that does the work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterJob

func RegisterJob[C any](meta job.Meta, cfg C, run job.RunFunc)

RegisterJob adds a downstream background job to the registry. One call = one row in the jobs table; call again with a different meta.Key (and, if you want, a different cfg) to register a second scheduled instance backed by the same RunFunc. The job is seeded on first boot with meta.DefaultCron; admins override from /manager/jobs.

app.RegisterJob(
    job.Meta{Key: "auto-get-data", Name: "Auto Get Data", Icon: "🌐", DefaultCron: "*/30 * * * *"},
    autogetdata.Config{Endpoint: "https://api.example.com"},
    autogetdata.Run,
)

cfg is a typed struct whose exported fields carry `wick:"..."` tags. Wick reflects it once here into `configs` rows scoped to meta.Key — Run reads live values via job.FromContext(ctx).Cfg(...). Pass an empty struct{}{} when the job has no runtime-editable knobs.

func RegisterJobNoConfig

func RegisterJobNoConfig(meta job.Meta, run job.RunFunc)

RegisterJobNoConfig is the variant for jobs that have nothing to configure at runtime. Equivalent to RegisterJob with an empty struct{} cfg.

func RegisterTool

func RegisterTool[C any](meta tool.Tool, cfg C, register tool.RegisterFunc)

RegisterTool adds a tool instance to the registry. One call = one card on the home grid; call again with a different meta.Key (and, if you want, a different cfg) to register a second instance backed by the same RegisterFunc.

app.RegisterTool(
    tool.Tool{Key: "convert-text", Name: "Convert Text", Icon: "Aa"},
    converttext.Config{InitText: "hello world"},
    converttext.Register,
)

cfg is a typed struct whose exported fields carry `wick:"..."` tags. Wick reflects it once here into `configs` rows scoped to meta.Key — handlers read the live values via c.Cfg(...) at request time.

func RegisterToolNoConfig

func RegisterToolNoConfig(meta tool.Tool, register tool.RegisterFunc)

RegisterToolNoConfig is the variant for tools that have nothing to configure at runtime — e.g. external redirect links. Equivalent to RegisterTool with an empty struct{} cfg.

func Run

func Run()

Run parses the command-line flags and starts either the HTTP server or the background worker. Subcommands:

server   — run the HTTP server (default)
worker   — run the background job worker

Blocks until shutdown.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL