MCPcopy
hub / github.com/apache/devlake / CreateAppBasicRes

Function CreateAppBasicRes

backend/core/runner/basic_res.go:39–54  ·  view source on GitHub ↗

CreateAppBasicRes returns an application level BasicRes instance based on .env/environment variables it is useful because multiple places need BasicRes including `main.go` `directrun` and `worker` keep in mind this function can be called only once

()

Source from the content-addressed store, hash-verified

37// it is useful because multiple places need BasicRes including `main.go` `directrun` and `worker`
38// keep in mind this function can be called only once
39func CreateAppBasicRes() context.BasicRes {
40 app_lock.Lock()
41 if app_inited {
42 panic(fmt.Errorf("CreateAppBasicRes can be called once"))
43 }
44 app_inited = true
45 app_lock.Unlock()
46 cfg := config.GetConfig()
47 logger := logruslog.Global
48 db, err := NewGormDb(cfg, logger)
49 if err != nil {
50 panic(err)
51 }
52 dalgorm.Init(cfg.GetString(plugin.EncodeKeyEnvStr))
53 return CreateBasicRes(cfg, logger, db)
54}
55
56// CreateBasicRes returns a BasicRes based on what was given
57func CreateBasicRes(cfg config.ConfigReader, logger log.Logger, db *gorm.DB) context.BasicRes {

Callers 1

DirectRunFunction · 0.85

Calls 5

NewGormDbFunction · 0.85
CreateBasicResFunction · 0.85
GetStringMethod · 0.80
GetConfigMethod · 0.65
InitMethod · 0.65

Tested by

no test coverage detected