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

domain

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: 2 Imported by: 0

README

Task resolution decisions

Import github.com/septagon-oss/platformkit/modules/task/domain from an ordinary Go application to decide task resolutions without PlatformKit's runtime. This package uses only the standard library. It shares the existing task lifecycle values; contracts retains compatible public constants.

Call Resolve(status, recorded, requested) with current task facts. Inspect the error first, then Changed: empty text is a valid new resolution. A false Changed leaves the original record and timestamp untouched. The executable example shows the API.

The caller owns authorization, current-state synchronization, timestamps and persistence. A decision is not a committed event. The existing SQL service locks and authorizes first, then applies the decision and publishes through the caller's transaction. Its fake shares the rule but does not model policy, transactions or rollback. Cross-module PlatformKit integrations continue to use the existing service contracts for those guarantees.

Run these local, service-free checks from the foundation repository:

go test ./modules/task/domain ./modules/task/contracts/tasktest
go list -deps -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./modules/task/domain

Tests must pass; the dependency listing must contain only this domain package. Database, authorization and outbox checks run through the repository's contribution workflow. Assignment and SLA decisions remain in their current owners. This extraction does not yet provide an independently persisted Task service or a frontend.

Documentation

Overview

Package domain owns portable task decisions. It does not load tasks, authorize callers, sample a clock, persist changes or publish events.

Index

Examples

Constants

View Source
const (
	StatusOpen         = "open"
	StatusAcknowledged = "acknowledged"
	StatusInProgress   = "in_progress"
	StatusResolved     = "resolved"
	StatusClosed       = "closed"
)

Lifecycle states retain the task entity's existing stored and wire values.

Variables

View Source
var (
	ErrClosed              = errors.New("a closed task cannot be resolved")
	ErrDifferentResolution = errors.New("this task is resolved with a different resolution")
)

Functions

This section is empty.

Types

type Resolution

type Resolution struct {
	Text    string
	Changed bool
}

Resolution describes a proposed change. Changed, rather than Text, determines whether to write: an empty resolution is valid. The zero value changes nothing. A decision does not establish authorization, persistence or event delivery.

func Resolve

func Resolve(status, recorded, requested string) (Resolution, error)

Resolve decides whether requested text closes the task's loop. Equal text (ignoring surrounding whitespace), or empty text, retries a resolved task without changing its stored text or timestamp. Different text is a conflict; a closed task refuses every resolution request.

Callers supply the current status and recorded text. For a change, they set StatusResolved, record Text and choose the resolution time when applying it. Other statuses resolve as before; entity validity and product-specific text requirements remain the caller's responsibility.

Example
package main

import (
	"fmt"

	"github.com/septagon-oss/platformkit/modules/task/domain"
)

func main() {
	decision, err := domain.Resolve(domain.StatusOpen, "", "  valve replaced  ")
	if err != nil {
		panic(err)
	}
	if decision.Changed {
		fmt.Println(domain.StatusResolved, decision.Text)
	}
}
Output:
resolved valve replaced

Jump to

Keyboard shortcuts

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