| 54 | } |
| 55 | |
| 56 | func New(ctx context.Context, opts *Options, logger *zap.Logger, st *storage.Client, ac *activity.Client, emailClient *email.Client) (*Runtime, error) { |
| 57 | if emailClient == nil { |
| 58 | emailClient = email.New(email.NewNoopSender()) |
| 59 | } |
| 60 | |
| 61 | rt := &Runtime{ |
| 62 | Email: emailClient, |
| 63 | opts: opts, |
| 64 | Logger: logger, |
| 65 | storage: st, |
| 66 | activity: ac, |
| 67 | queryCache: newQueryCache(opts.QueryCacheSizeBytes), |
| 68 | } |
| 69 | rt.securityEngine = newSecurityEngine(opts.SecurityEngineCacheSize, logger, rt) |
| 70 | |
| 71 | rt.connCache = rt.newConnectionCache() |
| 72 | |
| 73 | store, _, err := rt.AcquireSystemHandle(ctx, opts.MetastoreConnector) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | rt.metastore = store |
| 78 | reg, ok := rt.metastore.AsRegistry() |
| 79 | if !ok { |
| 80 | return nil, fmt.Errorf("metastore must be a valid registry") |
| 81 | } |
| 82 | |
| 83 | rt.registryCache = newRegistryCache(rt, reg, logger, ac) |
| 84 | err = rt.registryCache.init(ctx) |
| 85 | if err != nil { |
| 86 | return nil, err |
| 87 | } |
| 88 | |
| 89 | if opts.EnableConfigReloader { |
| 90 | rt.configReloader = newConfigReloader(rt) |
| 91 | } |
| 92 | |
| 93 | return rt, nil |
| 94 | } |
| 95 | |
| 96 | func (r *Runtime) AllowHostAccess() bool { |
| 97 | return r.opts.AllowHostAccess |