Browse Source

En cours de développement

master
losyme 8 months ago
parent
commit
1a60498325
  1. 15
      .editorconfig
  2. 22
      LICENSE
  3. 10
      README.md
  4. 26
      Taskfile.yml
  5. 42
      factory/factory.go
  6. 121
      factory/job.go
  7. 82
      factory/workflow.go
  8. 5
      go.mod
  9. 2
      go.sum
  10. 21
      sdk.go

15
.editorconfig

@ -0,0 +1,15 @@
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.go]
indent_style = tab
[*.md]
trim_trailing_whitespace = false

22
LICENSE

@ -1,9 +1,19 @@
MIT License
MIT License Copyright (c) 2021 losyme
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

10
README.md

@ -1,3 +1,11 @@
# sdk
AFAIRE
A FAIRE.
## Licence
MIT.
---
Copyright (c) 2021 `losyme`.

26
Taskfile.yml

@ -0,0 +1,26 @@
## https://taskfile.dev
##---------------------
version: '3'
tasks:
update:
cmds:
- go get -u forge.chapril.org/dune/jw
- go mod tidy
lint:
cmds:
- golangci-lint run
test:
cmds:
- go test -cover -v ./...
default:
cmds:
- task: lint
- task: test
git:
cmds:
- git add .
- git commit -m "En cours de développement"
- git push

42
factory/factory.go

@ -0,0 +1,42 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### sdk ####### Copyright (c) 2021 losyme ###################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package factory
import "forge.chapril.org/dune/jw"
type Model interface {
CreateJob(job *jw.Job) (*jw.Job, error)
CreateWorkflow(wf *jw.Workflow) (*jw.Workflow, error)
}
type Factory struct {
model Model
}
func New(model Model) *Factory {
return &Factory{
model: model,
}
}
func (f *Factory) NewJob(namespace, _type string) *Job {
return &Job{
job: jw.NewJob(namespace, _type),
model: f.model,
}
}
func (f *Factory) NewWorkflow(firstStep string, allSteps map[string]*jw.Step) *Workflow {
return &Workflow{
wf: jw.NewWorkflow(firstStep, allSteps),
model: f.model,
}
}
/*
######################################################################################################## @(°_°)@ #######
*/

121
factory/job.go

@ -0,0 +1,121 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### sdk ####### Copyright (c) 2021 losyme ###################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package factory
import (
"time"
"forge.chapril.org/dune/jw"
)
type Job struct {
job *jw.Job
model Model
}
func (job *Job) SetID(value string) *Job {
job.job.SetID(value)
return job
}
func (job *Job) SetName(value string) *Job {
job.job.SetName(value)
return job
}
func (job *Job) SetOrigin(value string) *Job {
job.job.SetOrigin(value)
return job
}
func (job *Job) SetPriority(value jw.Priority) *Job {
job.job.SetPriority(value)
return job
}
func (job *Job) SetPriorityNone() *Job {
job.job.SetPriorityNone()
return job
}
func (job *Job) SetPriorityLow() *Job {
job.job.SetPriorityLow()
return job
}
func (job *Job) SetPriorityMedium() *Job {
job.job.SetPriorityMedium()
return job
}
func (job *Job) SetPriorityHigh() *Job {
job.job.SetPriorityHigh()
return job
}
func (job *Job) SetPriorityCritical() *Job {
job.job.SetPriorityCritical()
return job
}
func (job *Job) SetPublic(key string, value interface{}) *Job {
job.job.SetPublic(key, value)
return job
}
func (job *Job) SetPrivate(key string, value interface{}) *Job {
job.job.SetPrivate(key, value)
return job
}
func (job *Job) SetRunAfter(value time.Time) *Job {
job.job.SetRunAfter(value)
return job
}
func (job *Job) SetExclusivity(value jw.Exclusivity) *Job {
job.job.SetExclusivity(value)
return job
}
func (job *Job) SetExclusivityNo() *Job {
job.job.SetExclusivityNo()
return job
}
func (job *Job) SetExclusivityItself() *Job {
job.job.SetExclusivityItself()
return job
}
func (job *Job) SetExclusivityNamespace() *Job {
job.job.SetExclusivityNamespace()
return job
}
func (job *Job) SetMaxRetries(value int) *Job {
job.job.SetMaxRetries(value)
return job
}
func (job *Job) SetMaxOccurences(value int) *Job {
job.job.SetMaxOccurences(value)
return job
}
func (job *Job) SetCategory(value string) *Job {
job.job.SetCategory(value)
return job
}
func (job *Job) CreateJob() (*jw.Job, error) {
return job.model.CreateJob(job.job)
}
/*
######################################################################################################## @(°_°)@ #######
*/

82
factory/workflow.go

@ -0,0 +1,82 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### sdk ####### Copyright (c) 2021 losyme ###################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package factory
import "forge.chapril.org/dune/jw"
type Workflow struct {
wf *jw.Workflow
model Model
}
func (wf *Workflow) SetID(value string) *Workflow {
wf.wf.SetID(value)
return wf
}
func (wf *Workflow) SetType(value string) *Workflow {
wf.wf.SetType(value)
return wf
}
func (wf *Workflow) SetDescription(value string) *Workflow {
wf.wf.SetDescription(value)
return wf
}
func (wf *Workflow) SetOrigin(value string) *Workflow {
wf.wf.SetOrigin(value)
return wf
}
func (wf *Workflow) SetPriority(value jw.Priority) *Workflow {
wf.wf.SetPriority(value)
return wf
}
func (wf *Workflow) SetPriorityNone() *Workflow {
wf.wf.SetPriorityNone()
return wf
}
func (wf *Workflow) SetPriorityLow() *Workflow {
wf.wf.SetPriorityLow()
return wf
}
func (wf *Workflow) SetPriorityMedium() *Workflow {
wf.wf.SetPriorityMedium()
return wf
}
func (wf *Workflow) SetPriorityHigh() *Workflow {
wf.wf.SetPriorityHigh()
return wf
}
func (wf *Workflow) SetPriorityCritical() *Workflow {
wf.wf.SetPriorityCritical()
return wf
}
func (wf *Workflow) SetData(key string, value interface{}) *Workflow {
wf.wf.SetData(key, value)
return wf
}
func (wf *Workflow) SetExternalID(value string) *Workflow {
wf.wf.SetExternalID(value)
return wf
}
func (wf *Workflow) CreateWorkflow() (*jw.Workflow, error) {
return wf.model.CreateWorkflow(wf.wf)
}
/*
######################################################################################################## @(°_°)@ #######
*/

5
go.mod

@ -0,0 +1,5 @@
module forge.chapril.org/dune/sdk
go 1.17
require forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea

2
go.sum

@ -0,0 +1,2 @@
forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea h1:EC1XXrDQ6E7Oed04iZFKsk2dbxJORBH2G+UxBFz42j4=
forge.chapril.org/dune/jw v0.0.0-20211114170701-4b66b0d705ea/go.mod h1:7CyK2ZvzHntSlOZ7kWcqVhkmUzlE0QI3uKW9kPbNbOY=

21
sdk.go

@ -0,0 +1,21 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### sdk ####### Copyright (c) 2021 losyme ###################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package sdk
type Logger interface {
Trace(msg string, kv ...interface{})
Debug(msg string, kv ...interface{})
Info(msg string, kv ...interface{})
Notice(msg string, kv ...interface{})
Warning(msg string, kv ...interface{})
Error(msg string, kv ...interface{})
Fatal(msg string, kv ...interface{})
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save