| 162 | } |
| 163 | |
| 164 | func NewServer( |
| 165 | lifecycleCtx context.Context, |
| 166 | apiVersion string, |
| 167 | accessURL *url.URL, |
| 168 | id uuid.UUID, |
| 169 | organizationID uuid.UUID, |
| 170 | logger slog.Logger, |
| 171 | provisioners []database.ProvisionerType, |
| 172 | tags Tags, |
| 173 | db database.Store, |
| 174 | ps pubsub.Pubsub, |
| 175 | acquirer *Acquirer, |
| 176 | tel telemetry.Reporter, |
| 177 | tracer trace.Tracer, |
| 178 | quotaCommitter *atomic.Pointer[proto.QuotaCommitter], |
| 179 | auditor *atomic.Pointer[audit.Auditor], |
| 180 | templateScheduleStore *atomic.Pointer[schedule.TemplateScheduleStore], |
| 181 | userQuietHoursScheduleStore *atomic.Pointer[schedule.UserQuietHoursScheduleStore], |
| 182 | usageInserter *atomic.Pointer[usage.Inserter], |
| 183 | deploymentValues *codersdk.DeploymentValues, |
| 184 | options Options, |
| 185 | enqueuer notifications.Enqueuer, |
| 186 | prebuildsOrchestrator *atomic.Pointer[prebuilds.ReconciliationOrchestrator], |
| 187 | metrics *Metrics, |
| 188 | experiments codersdk.Experiments, |
| 189 | ) (proto.DRPCProvisionerDaemonServer, error) { |
| 190 | // Fail-fast if pointers are nil |
| 191 | if lifecycleCtx == nil { |
| 192 | return nil, xerrors.New("ctx is nil") |
| 193 | } |
| 194 | if quotaCommitter == nil { |
| 195 | return nil, xerrors.New("quotaCommitter is nil") |
| 196 | } |
| 197 | if auditor == nil { |
| 198 | return nil, xerrors.New("auditor is nil") |
| 199 | } |
| 200 | if templateScheduleStore == nil { |
| 201 | return nil, xerrors.New("templateScheduleStore is nil") |
| 202 | } |
| 203 | if userQuietHoursScheduleStore == nil { |
| 204 | return nil, xerrors.New("userQuietHoursScheduleStore is nil") |
| 205 | } |
| 206 | if usageInserter == nil { |
| 207 | return nil, xerrors.New("usageCollector is nil") |
| 208 | } |
| 209 | if deploymentValues == nil { |
| 210 | return nil, xerrors.New("deploymentValues is nil") |
| 211 | } |
| 212 | if acquirer == nil { |
| 213 | return nil, xerrors.New("acquirer is nil") |
| 214 | } |
| 215 | if tags == nil { |
| 216 | return nil, xerrors.Errorf("tags is nil") |
| 217 | } |
| 218 | if err := tags.Valid(); err != nil { |
| 219 | return nil, xerrors.Errorf("invalid tags: %w", err) |
| 220 | } |
| 221 | if options.AISeatTracker == nil { |