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 ¶
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 ¶
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 ¶
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