Help us shape the future of Go! Take the 2026 Go Developer Survey

task

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Task module

modules/task is the reference module: one entity, a rest.Spec at /api/v1/task/tasks guarded by task:read and task:update, explicit lifecycle commands, an optional tenant-qualified policy check and the SLA sweep job. Read module.go for the manifest, contracts/ for the entity, service, events, permissions and the conformance suite, and domain/ for the resolution rule that needs no runtime.

Its SQL is migrations/, embedded and exported as task.Migrations; the manifest hands the kernel the same files, and a test composes it with dbtest.Schema(t, task.Migrations).

Compose it with task.Deps{Service, Policy, Tenants, SweepEvery}; Policy is optional and modules/auth/policies shows the Topaz adapter. The generated admin screens appear at /admin/task/tasks with no code of the module's own. make test TEST_PACKAGES=./modules/task/... needs the development database; the domain package's tests need nothing.

Documentation

Overview

Package task is the module manifest: what the kernel needs to know about tasks that it cannot learn from a function call.

It is the shape every module follows: contracts/, internal/, and one exported function taking a struct of typed dependencies and returning a module.Module. The application constructs it in dependency order. Compilation checks the dependency types; composition tests exercise the values supplied.

Index

Constants

This section is empty.

Variables

View Source
var Migrations = db.MigrationSource{
	Owner:  "task",
	Files:  db.Sub(schema, "migrations"),
	Adopts: []db.Adoption{{Owner: "platformkit", Versions: []int64{4}}},
}

Migrations is this module's SQL as one source — the tasks table and its indexes — owned as "task". The manifest hands the kernel the same files and adoption, and a test composes the schema it needs beside the foundation: dbtest.Schema(t, task.Migrations).

The files keep the version numbers they had when the foundation applied them under its own name, so an installation migrated before this module owned its SQL is adopted by checksum rather than migrated again (see db.Adoption and docs/adr/0011). New files continue from the highest number.

Functions

func Module

func Module(deps Deps) module.Module

Module mounts one shared lifecycle implementation for routes and jobs.

func NewService added in v1.1.0

func NewService() contracts.Service

NewService constructs task lifecycle commands for application composition. Pass the returned value through Deps.Service to share it with task routes.

func NewServiceWithPolicy added in v1.1.0

func NewServiceWithPolicy(policy tenancy.Policy) contracts.Service

NewServiceWithPolicy adds resource decisions to assignment and resolution. The caller still owns route grants, current identity and tenant transactions.

Types

type Deps

type Deps struct {
	// Service shares one lifecycle implementation with product callers. A
	// policy-enabled composition supplies NewServiceWithPolicy here and hands
	// the same service to its other modules.
	Service contracts.Service

	// Policy optionally refines assignment and resolution for the locked task.
	// Existing route grants still apply. System SLA maintenance is independent.
	// Supply either Policy or a preconfigured Service, never both.
	Policy tenancy.Policy

	// Tenants is how the SLA sweep reaches active tenants. The application
	// supplies tenant/contracts.Active over its tenant service.
	Tenants jobs.TenantLister

	// SweepEvery is how often the sweep runs; zero means a minute. The promise
	// this module keeps is measured in hours, so a minute of lag on noticing a
	// breach is free and anything faster is a query per tenant per tick for
	// nobody's benefit. A test sets it lower.
	SweepEvery time.Duration
}

Deps is what this module cannot make for itself: a struct rather than a parameter list, so adding one is a named field at every call site rather than a fourth positional argument. Every module follows this, and an empty Deps is a module that needs nothing.

Directories

Path Synopsis
Package contracts is everything another module, an app or a test may know about tasks: the entity, the events, the permissions and the Service interface.
Package contracts is everything another module, an app or a test may know about tasks: the entity, the events, the permissions and the Service interface.
tasktest
Package tasktest is the conformance suite for contracts.Service, and a fake that passes it.
Package tasktest is the conformance suite for contracts.Service, and a fake that passes it.
Package domain owns portable task decisions.
Package domain owns portable task decisions.
Package internal is every implementation of the task module.
Package internal is every implementation of the task module.

Jump to

Keyboard shortcuts

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