This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# platform
|
||||
|
||||
Only shared **technical mechanisms** may live here. No shared domain objects. Platform packages cannot import semantic modules.
|
||||
@@ -0,0 +1,9 @@
|
||||
package clock
|
||||
|
||||
import "time"
|
||||
|
||||
type Clock interface{ Now() time.Time }
|
||||
|
||||
type Real struct{}
|
||||
|
||||
func (Real) Now() time.Time { return time.Now().UTC() }
|
||||
@@ -0,0 +1,22 @@
|
||||
package errors
|
||||
|
||||
type Kind string
|
||||
|
||||
const (
|
||||
Rejected Kind = "REJECTED"
|
||||
Failed Kind = "FAILED"
|
||||
UnknownOutcome Kind = "UNKNOWN_OUTCOME"
|
||||
TemporarilyUnavailable Kind = "TEMPORARILY_UNAVAILABLE"
|
||||
Conflict Kind = "CONFLICT"
|
||||
Stale Kind = "STALE"
|
||||
Unauthorized Kind = "UNAUTHORIZED"
|
||||
Unsupported Kind = "UNSUPPORTED"
|
||||
)
|
||||
|
||||
type Error struct {
|
||||
Kind Kind
|
||||
Code string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e Error) Error() string { return e.Message }
|
||||
@@ -0,0 +1,19 @@
|
||||
package ids
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ID is a transport-neutral opaque identifier primitive. Domain packages wrap it
|
||||
// in strong semantic ID types; do not pass bare ID across semantic boundaries.
|
||||
type ID string
|
||||
|
||||
func New() (ID, error) {
|
||||
var b [16]byte
|
||||
if _, err := rand.Read(b[:]); err != nil {
|
||||
return "", fmt.Errorf("generate id: %w", err)
|
||||
}
|
||||
return ID(hex.EncodeToString(b[:])), nil
|
||||
}
|
||||
Reference in New Issue
Block a user