chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package workspacelifecycle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"inbox/internal/app/workspaceprovision"
|
||||
"inbox/internal/app/workspaceruntime"
|
||||
"inbox/internal/domain/workspace"
|
||||
)
|
||||
|
||||
type Provisioner interface {
|
||||
Provision(ctx context.Context, req workspaceprovision.ProvisionRequest) (workspace.Workspace, workspaceruntime.Runtime, error)
|
||||
}
|
||||
|
||||
type RuntimeManager interface {
|
||||
Ensure(ctx context.Context, workspaceID string) (workspace.Workspace, workspaceruntime.Runtime, error)
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
provision Provisioner
|
||||
runtime RuntimeManager
|
||||
}
|
||||
|
||||
func NewService(provision Provisioner, runtime RuntimeManager) *Service {
|
||||
return &Service{
|
||||
provision: provision,
|
||||
runtime: runtime,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Provision(ctx context.Context, req workspaceprovision.ProvisionRequest) (workspace.Workspace, workspaceruntime.Runtime, error) {
|
||||
if s.provision == nil {
|
||||
return workspace.Workspace{}, workspaceruntime.Runtime{}, fmt.Errorf("workspace provisioning is not configured")
|
||||
}
|
||||
return s.provision.Provision(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Service) Ensure(ctx context.Context, workspaceID string) (workspace.Workspace, workspaceruntime.Runtime, error) {
|
||||
if s.runtime == nil {
|
||||
return workspace.Workspace{}, workspaceruntime.Runtime{}, fmt.Errorf("workspace runtime is not configured")
|
||||
}
|
||||
return s.runtime.Ensure(ctx, workspaceID)
|
||||
}
|
||||
Reference in New Issue
Block a user