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

Method ProvideEssentials

c.go:331–370  ·  view source on GitHub ↗

ProvideEssentials adds the default core dependencies to the core.

()

Source from the content-addressed store, hash-verified

329
330// ProvideEssentials adds the default core dependencies to the core.
331func (c *C) ProvideEssentials() {
332 type coreDependencies struct {
333 di.Out
334
335 Env contract.Env
336 AppName contract.AppName
337 Container contract.Container
338 ConfigUnmarshaler contract.ConfigUnmarshaler
339 ConfigAccessor contract.ConfigAccessor
340 ConfigRouter contract.ConfigRouter
341 ConfigWatcher contract.ConfigWatcher
342 DIPopulator contract.DIPopulator
343 Logger log.Logger
344 LevelLogger logging.LevelLogger
345 Dispatcher contract.Dispatcher
346 DefaultConfigs []config.ExportedConfig `group:"config,flatten"`
347 }
348
349 c.provide(func() coreDependencies {
350 coreDependencies := coreDependencies{
351 Env: c.Env,
352 AppName: c.AppName,
353 Container: c.Container,
354 ConfigUnmarshaler: c.ConfigAccessor,
355 ConfigAccessor: c.ConfigAccessor,
356 Logger: c.baseLogger,
357 LevelLogger: c.LevelLogger,
358 Dispatcher: c.Dispatcher,
359 DIPopulator: di.IntoPopulator(c.di),
360 DefaultConfigs: provideDefaultConfig(),
361 }
362 if cc, ok := c.ConfigAccessor.(contract.ConfigRouter); ok {
363 coreDependencies.ConfigRouter = cc
364 }
365 if cc, ok := c.ConfigAccessor.(contract.ConfigWatcher); ok {
366 coreDependencies.ConfigWatcher = cc
367 }
368 return coreDependencies
369 })
370}
371
372// Serve runs the serve command bundled in the core.
373// For larger projects, consider use full-featured ServeModule instead of calling serve directly.

Callers 15

DefaultFunction · 0.80
TestC_ServeFunction · 0.80
TestC_ServeDisableFunction · 0.80
TestC_DefaultFunction · 0.80
TestHookFunction · 0.80
ExampleFunction · 0.80
TestProvideGORMMetricsFunction · 0.80
TestProvideRedisMetricsFunction · 0.80
TestProvideKafkaMetricsFunction · 0.80
ExampleFunction · 0.80
TestCollectorFunction · 0.80

Calls 3

provideMethod · 0.95
IntoPopulatorFunction · 0.92
provideDefaultConfigFunction · 0.85

Tested by 15

TestC_ServeFunction · 0.64
TestC_ServeDisableFunction · 0.64
TestC_DefaultFunction · 0.64
TestHookFunction · 0.64
ExampleFunction · 0.64
TestProvideGORMMetricsFunction · 0.64
TestProvideRedisMetricsFunction · 0.64
TestProvideKafkaMetricsFunction · 0.64
ExampleFunction · 0.64
TestCollectorFunction · 0.64
ExampleFunction · 0.64