MCPcopy Index your code
hub / github.com/DoNewsCode/core / New

Function New

c.go:159–191  ·  view source on GitHub ↗

New creates a new bare-bones C.

(opts ...CoreOption)

Source from the content-addressed store, hash-verified

157
158// New creates a new bare-bones C.
159func New(opts ...CoreOption) *C {
160 values := coreValues{
161 configStack: []config.ProviderSet{},
162 configWatcher: nil,
163 configProvider: ProvideConfig,
164 appNameProvider: ProvideAppName,
165 envProvider: ProvideEnv,
166 loggerProvider: ProvideLogger,
167 diProvider: ProvideDi,
168 eventDispatcherProvider: ProvideEventDispatcher,
169 }
170 for _, f := range opts {
171 f(&values)
172 }
173 conf := values.configProvider(values.configStack, values.configWatcher)
174 env := values.envProvider(conf)
175 appName := values.appNameProvider(conf)
176 logger := values.loggerProvider(conf, appName, env)
177 diContainer := values.diProvider(conf)
178 dispatcher := values.eventDispatcherProvider(conf)
179
180 c := C{
181 AppName: appName,
182 Env: env,
183 ConfigAccessor: config.WithAccessor(conf),
184 LevelLogger: logging.WithLevel(logger),
185 Container: &container.Container{},
186 Dispatcher: dispatcher,
187 di: diContainer,
188 baseLogger: logger,
189 }
190 return &c
191}
192
193// Default creates a core.C under its default state. Core dependencies are
194// already provided, and the config module and serve module are bundled.

Callers 15

ExampleC_AddModuleFuncFunction · 0.92
ExampleC_ProvideFunction · 0.92
ExampleC_stackFunction · 0.92
TestHookFunction · 0.92
ExampleFunction · 0.92
Example_modulesFunction · 0.92
TestBindFunction · 0.92
TestNameFunction · 0.92
TestAsFunction · 0.92
TestLocationForPCFunction · 0.92

Calls 2

WithAccessorFunction · 0.92
WithLevelFunction · 0.92

Tested by 15

ExampleC_AddModuleFuncFunction · 0.74
ExampleC_ProvideFunction · 0.74
ExampleC_stackFunction · 0.74
TestHookFunction · 0.74
ExampleFunction · 0.74
Example_modulesFunction · 0.74
TestBindFunction · 0.74
TestNameFunction · 0.74
TestAsFunction · 0.74
TestLocationForPCFunction · 0.74