(options *options.ControllerOptions)
| 32 | ) |
| 33 | |
| 34 | func Init(options *options.ControllerOptions) (controller *Controller, err error) { |
| 35 | controller = &Controller{ |
| 36 | runOptions: options, |
| 37 | FuncletClient: client.NewFuncletClient(options.FuncletClientOptions), |
| 38 | } |
| 39 | |
| 40 | for { |
| 41 | err := controller.initContainers() |
| 42 | if err != nil { |
| 43 | logs.Errorf("get container failed: %s", err.Error()) |
| 44 | time.Sleep(time.Second) |
| 45 | } else { |
| 46 | break |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | controller.runtimeControl, err = rtctrl.NewRuntimeClient(options.RuntimeConfigOptions, |
| 51 | options.DispatcherV2Options, controller.runtimeDispatcher) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | cacheConfig := function.DefaultCacheExpirationConfigs() |
| 56 | cacheConfig[function.CacheTypeAlias] = options.AliasCacheOptions.CacheExpiration |
| 57 | controller.dataStorer, err = function.NewDataStorer(options.RepositoryOptions, function.NewStorageCache(cacheConfig)) |
| 58 | insideRepositoryOptions := options.RepositoryOptions |
| 59 | insideRepositoryOptions.Version = "inside-v1" |
| 60 | controller.insideDataStorer, err = function.NewDataStorer(insideRepositoryOptions, function.NewStorageCache(cacheConfig)) |
| 61 | if options.HTTPEnhanced { |
| 62 | if options.HttpTriggerRepositoryOptions.IsEmpty() { |
| 63 | controller.httpTriggerDataStorer, err = function.NewDataStorer(insideRepositoryOptions, function.NewStorageCache(cacheConfig)) |
| 64 | } else { |
| 65 | controller.httpTriggerDataStorer, err = function.NewDataStorer(options.HttpTriggerRepositoryOptions, function.NewStorageCache(cacheConfig)) |
| 66 | } |
| 67 | } |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | go controller.cronTask(options) |
| 72 | if options.RecommendedOptions.Features.EnableMetrics { |
| 73 | go controller.metricTask(options) |
| 74 | } |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | func (controller *Controller) initContainers() (err error) { |
| 79 | // TODO: sync from funclet for more runtime information |
no test coverage detected