Documentation
¶
Index ¶
- Constants
- Variables
- func AllInstanceMetaPattern(namespace string) string
- func ConnInfo(c Component) string
- func HistoryKey(i uint64) string
- func InstanceKeyPattern(namespace, appID, instanceID string) string
- func InstanceMetaPattern(namespace, appID string) string
- func InstancePrefix(namespace, appID, instanceID string) string
- func ParseAppID(key string) (string, bool)
- func ParseInstanceID(key string) (string, bool)
- func SeedForTest(ctx context.Context, s Store, key string, value []byte) error
- func SetVerbose(v bool)
- func WorkflowActorType(namespace, appID string) string
- type Component
- type HostLookup
- type PathLookup
- type Record
- type RecordReader
- type SecretRef
- type Store
Constants ¶
const ( KeyDelimiter = "||" SuffixMetadata = "metadata" SuffixCustomStatus = "customStatus" HistoryPrefix = "history-" )
Variables ¶
var ErrUnsupported = errors.New("unsupported state store type")
ErrUnsupported is returned by New when the component type is not one of the four supported backends (state.redis, state.sqlite, state.postgresql/postgres, state.mongodb).
Functions ¶
func AllInstanceMetaPattern ¶
AllInstanceMetaPattern is a KeysLike LIKE pattern matching every instance's metadata key across ALL app-ids in the namespace ("%" matches both the leading app-id segment and the app-id inside the actor type).
func ConnInfo ¶
ConnInfo returns a short, human-readable connection summary for a component, suitable for display in the UI. It NEVER includes credentials (passwords or user info). Returns "" when no usable, non-secret metadata is present.
func HistoryKey ¶ added in v0.0.20
HistoryKey returns the key suffix of an instance's i-th history entry, matching Dapr's naming: "history-" + i zero-padded to at least 6 digits. Prepend InstancePrefix to get the full key.
func InstanceKeyPattern ¶
InstanceKeyPattern matches every state key belonging to one instance.
func InstanceMetaPattern ¶
InstanceMetaPattern is a KeysLike LIKE pattern matching every instance's metadata key for an app ("%" matches the instance-id segment).
func InstancePrefix ¶
InstancePrefix is the "<appId>||<actorType>||<instanceID>||" prefix.
func ParseAppID ¶
ParseAppID returns the app-id segment (segment[0]) of a "||"-joined workflow key. Returns ok=false for a malformed key (fewer than three segments or an empty app-id segment).
func ParseInstanceID ¶
ParseInstanceID returns the instance-id segment of a "||"-joined workflow key.
func SeedForTest ¶
SeedForTest is a helper for integration tests that upserts a raw byte value through the public Store interface.
func SetVerbose ¶ added in v0.0.8
func SetVerbose(v bool)
SetVerbose lets the backend state stores emit informational logs; wire it to the dashboard's --verbose flag.
func WorkflowActorType ¶
WorkflowActorType builds the Dapr workflow actor type for an app.
Types ¶
type Component ¶
type Component struct {
Name string // metadata.name
Type string // spec.type, e.g. "state.redis"
Version string // spec.version
Metadata map[string]string // spec.metadata name->value (inline only)
SecretRefs map[string]SecretRef // spec.metadata name->secretKeyRef/envRef (no inline value)
SecretStore string // auth.secretStore
Path string // source file path (for display / disambiguation)
}
Component is the parsed subset of a Dapr state-store component YAML we need.
func Translate ¶
func Translate(c Component, hosts HostLookup, paths PathLookup) Component
Translate rewrites c's connection metadata for access from the host: state.redis redisHost, state.postgresql/postgres connection strings (URL or key=value DSN), and state.sqlite file paths. Only exact lookup hits are rewritten — foreign hostnames pass through so a connection failure stays honest. Copy-on-write: c is never mutated; the returned Component carries a fresh Metadata map only when something changed.
type HostLookup ¶
HostLookup resolves a compose-network hostname + port to a host-reachable "host:port". ok=false leaves the original address untouched.
type PathLookup ¶
PathLookup resolves a container-internal file path to a host path.
type Record ¶ added in v0.0.18
type Record struct {
Key string
Value []byte
ETag string // "" when the backend has none for this entry
TTLExpire *time.Time // nil when the entry has no TTL
// ContentType is nil for all four supported backends today; it is carried
// through so it starts working for free if contrib begins populating it.
ContentType string
}
Record is one state entry with the metadata the four supported backends actually expose. There is deliberately no created/modified timestamp: components-contrib never surfaces one, even for the SQL backends whose tables physically store it (see the design spec).
type RecordReader ¶ added in v0.0.18
RecordReader is the metadata-preserving bulk read path. ccStore implements it; consumers type-assert for it rather than it being part of Store, mirroring how ccStore.Keys asserts for state.KeysLiker.
type SecretRef ¶
type SecretRef struct {
// Kind is "secretKeyRef" or "envRef", mirroring secrets.Ref.Kind. The zero
// value ("") is treated as "secretKeyRef" by every consumer, so existing
// literals built before envRef support was added keep working unchanged.
Kind string
Name string // secretKeyRef.name, or the env var name for envRef
Key string // secretKeyRef.key (the key within that secret); unused for envRef
}
SecretRef is a Dapr secretKeyRef or envRef metadata reference.
type Store ¶
type Store interface {
// Keys lists keys matching a LIKE pattern, with opaque cursor paging.
Keys(ctx context.Context, pattern string, token string, pageSize int) (keys []string, next string, err error)
Get(ctx context.Context, key string) ([]byte, error)
BulkGet(ctx context.Context, keys []string) (map[string][]byte, error)
Delete(ctx context.Context, key string) error
// Set upserts a raw byte value at key. Used by integration tests to seed state.
Set(ctx context.Context, key string, value []byte) error
Close() error
}
Store is the read + write + delete surface the workflow service needs.