-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
112 lines (90 loc) · 3.13 KB
/
types.go
File metadata and controls
112 lines (90 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (c) 2024 OrigAdmin. All rights reserved.
*/
package runtime
import (
"context"
"github.com/origadmin/runtime/contracts/component"
"github.com/origadmin/runtime/engine"
)
// --- Engine Metadata Types Aliases ---
type Category = component.Category
type Scope = component.Scope
type Priority = component.Priority
type Provider = component.Provider
type Handle = component.Handle
type Registry = component.Registry
type Container = component.Container
// --- Category Conventions ---
const (
CategoryInfrastructure Category = "infrastructure"
CategoryLogger Category = "logger"
CategoryRegistrar Category = "registrar"
CategoryDiscovery Category = "discovery"
CategoryClient Category = "client"
CategoryServer Category = "server"
CategoryMiddleware Category = "middleware"
CategoryDatabase Category = "database"
CategoryCache Category = "cache"
CategoryObjectStore Category = "objectstore"
CategoryQueue Category = "queue"
CategoryTask Category = "task"
CategoryMail Category = "mail"
CategoryStorage Category = "storage"
CategorySecurity Category = "security"
CategorySkipper Category = "skipper"
)
// --- Scope Conventions ---
const (
// GlobalScope is the default fallback scope for the system.
GlobalScope Scope = ""
// ServerScope is the standard scope for server-side components.
ServerScope Scope = "server"
// ClientScope is the standard scope for client-side components.
ClientScope Scope = "client"
)
// --- Engine Component Aliases ---
type (
ConfigResolver = component.ConfigResolver
RequirementResolver = component.RequirementResolver
Registration = component.Registration
ModuleConfig = component.ModuleConfig
ConfigEntry = component.ConfigEntry
RegistrationOptions = component.RegistrationOptions
InOption = component.InOption
Locator = component.Locator
LoadOption = component.LoadOption
)
type (
AppOption = Option
RegisterOption = component.RegisterOption
)
// --- Engine Options (Perspective & Load) ---
// WithInScope specifies the perspective scope.
func WithInScope(s Scope) InOption {
return engine.WithInScope(s)
}
// WithInTags specifies the perspective tags.
func WithInTags(tags ...string) InOption {
return engine.WithInTags(tags...)
}
// WithTag specifies the tag for a component.
func WithTag(tag string) RegisterOption {
return engine.WithTag(tag)
}
// WithResolver specifies a local config resolver for a component.
func WithResolver(res component.ConfigResolver) RegisterOption {
return engine.WithConfigResolverOption(res)
}
// WithScopes specifies the scopes for a component.
func WithScopes(ss ...Scope) RegisterOption {
return engine.WithScopes(ss...)
}
// WithEntries specifies the default entries for a component.
func WithEntries(names ...string) RegisterOption {
return engine.WithDefaultEntries(names...)
}
// WithRequirement specifies a local requirement resolver for a component.
func WithRequirement(f func(ctx context.Context, h component.Handle, purpose string) (any, error)) RegisterOption {
return engine.WithRequirementResolverOption(f)
}