Browse Source

En cours de développement

master
losyme 3 months ago
parent
commit
ae03e869b5
  1. 4
      internal/components/components.go
  2. 14
      internal/model/jobs.go
  3. 6
      internal/model/model.go
  4. 4
      internal/model/validate.go
  5. 4
      internal/model/workflows.go

4
internal/components/components.go

@ -9,11 +9,13 @@ package components
import (
"forge.chapril.org/dune/jw"
"forge.chapril.org/losyme/minikit/pkg/components"
"forge.chapril.org/dune/dune/internal/model"
)
type Components struct {
*components.Components
Model jw.Model
Model *model.Model
Storage jw.Storage
}

14
internal/model/jobs.go

@ -13,7 +13,7 @@ import (
"forge.chapril.org/losyme/errors"
)
func (m *model) insertJob(job *jw.Job) (bool, error) {
func (m *Model) insertJob(job *jw.Job) (bool, error) {
done, err := m.storage.InsertJob(job)
if err != nil {
m.logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ -37,7 +37,7 @@ func (m *model) insertJob(job *jw.Job) (bool, error) {
return true, nil
}
func (m *model) CreateJob(job *jw.Job) (*jw.Job, error) {
func (m *Model) CreateJob(job *jw.Job) (*jw.Job, error) {
if err := m.validateJob(job); err != nil {
return nil, errors.Wrap( ///////////////////////////////////////////////////////////////////////////////////////
ErrValidation,
@ -60,24 +60,24 @@ func (m *model) CreateJob(job *jw.Job) (*jw.Job, error) {
return nil, nil
}
func (m *model) NextJob(namespace string) (*jw.Job, error) {
func (m *Model) NextJob(namespace string) (*jw.Job, error) {
return nil, nil
}
func (m *model) UpdateJob(job *jw.Job) (*jw.Job, error) {
func (m *Model) UpdateJob(job *jw.Job) (*jw.Job, error) {
return nil, nil
}
func (m *model) NotifyJob(id string, data interface{}) error {
func (m *Model) NotifyJob(id string, data interface{}) error {
//@todo
return nil
}
func (m *model) SetJobPriority(id string, priority jw.Priority) error {
func (m *Model) SetJobPriority(id string, priority jw.Priority) error {
return m.storage.SetJobPriority(id, priority)
}
func (m *model) SetJobRunAfter(id string, duration time.Duration) error {
func (m *Model) SetJobRunAfter(id string, duration time.Duration) error {
return m.storage.SetJobRunAfter(id, duration)
}

6
internal/model/model.go

@ -17,17 +17,17 @@ const (
ErrValidation = errors.Sentinel("validation error")
)
type model struct {
type Model struct {
logger *logger.Component
storage jw.Storage
}
func New(cfg *Config) (jw.Model, error) {
func New(cfg *Config) (*Model, error) {
if err := cfg.validate(); err != nil {
return nil, err
}
m := &model{
m := &Model{
logger: cfg.Logger,
storage: cfg.Storage,
}

4
internal/model/validate.go

@ -35,7 +35,7 @@ func validatePriority(p *jw.Priority) {
}
}
func (m *model) validateJob(job *jw.Job) error {
func (m *Model) validateJob(job *jw.Job) error {
if err := m.storage.ValidateJob(job); err != nil {
return err
}
@ -155,7 +155,7 @@ func validateStep(wf *jw.Workflow, step *jw.Step) error {
return validateNext(wf, step.Next)
}
func (m *model) validateWorkflow(wf *jw.Workflow) error {
func (m *Model) validateWorkflow(wf *jw.Workflow) error {
if err := m.storage.ValidateWorkflow(wf); err != nil {
return err
}

4
internal/model/workflows.go

@ -11,7 +11,7 @@ import (
"forge.chapril.org/losyme/errors"
)
func (m *model) CreateWorkflow(wf *jw.Workflow) (*jw.Workflow, error) {
func (m *Model) CreateWorkflow(wf *jw.Workflow) (*jw.Workflow, error) {
if err := m.validateWorkflow(wf); err != nil {
return nil, errors.Wrap( ///////////////////////////////////////////////////////////////////////////////////////
ErrValidation,
@ -22,7 +22,7 @@ func (m *model) CreateWorkflow(wf *jw.Workflow) (*jw.Workflow, error) {
return nil, nil
}
func (m *model) SetWorkflowPriority(id string, priority jw.Priority) error {
func (m *Model) SetWorkflowPriority(id string, priority jw.Priority) error {
return m.storage.SetWorkflowPriority(id, priority)
}

Loading…
Cancel
Save