Skip to content

Commit 8f2b145

Browse files
feat: Implemented full distributed job sheduler
0 parents  commit 8f2b145

58 files changed

Lines changed: 6057 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE_URL="http://localhost:8080"

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
backend/scheduler.log
2+
backend/main.exe
3+
node_modules/
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
pnpm-debug.log*
11+
lerna-debug.log*
12+
13+
node_modules
14+
dist
15+
dist-ssr
16+
*.local
17+
18+
19+
# Editor directories and files
20+
.vscode/*
21+
!.vscode/extensions.json
22+
.idea
23+
.DS_Store
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?
29+
backend/scheduler.log

backend/cmd/client/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"job-scheduler/internal/usecase"
6+
)
7+
8+
func main() {
9+
client := usecase.NewClient("http://localhost:8080")
10+
if err := client.Run(); err != nil {
11+
fmt.Println(err)
12+
}
13+
}

backend/cmd/server/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import "job-scheduler/internal/app"
4+
5+
func main() {
6+
app.CreateServer()
7+
8+
}

backend/cmd/worker/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"job-scheduler/internal/usecase"
6+
)
7+
8+
func main() {
9+
worker := usecase.NewWorker()
10+
if err := worker.Run(); err != nil {
11+
fmt.Println(err)
12+
}
13+
}

backend/docs/docs.go

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Package docs Code generated by swaggo/swag. DO NOT EDIT
2+
package docs
3+
4+
import "github.com/swaggo/swag"
5+
6+
const docTemplate = `{
7+
"schemes": {{ marshal .Schemes }},
8+
"swagger": "2.0",
9+
"info": {
10+
"description": "{{escape .Description}}",
11+
"title": "{{.Title}}",
12+
"contact": {},
13+
"version": "{{.Version}}"
14+
},
15+
"host": "{{.Host}}",
16+
"basePath": "{{.BasePath}}",
17+
"paths": {
18+
"/job": {
19+
"post": {
20+
"description": "parsing Json and pushing job",
21+
"consumes": [
22+
"application/json"
23+
],
24+
"produces": [
25+
"application/json"
26+
],
27+
"summary": "Accept Job",
28+
"parameters": [
29+
{
30+
"description": "Job data",
31+
"name": "job",
32+
"in": "body",
33+
"required": true,
34+
"schema": {
35+
"$ref": "#/definitions/entity.Job"
36+
}
37+
}
38+
],
39+
"responses": {
40+
"200": {
41+
"description": "OK",
42+
"schema": {
43+
"$ref": "#/definitions/entity.Job"
44+
}
45+
},
46+
"400": {
47+
"description": "Invalid Json",
48+
"schema": {
49+
"type": "string"
50+
}
51+
},
52+
"405": {
53+
"description": "Only post method allowed",
54+
"schema": {
55+
"type": "string"
56+
}
57+
},
58+
"500": {
59+
"description": "internal error",
60+
"schema": {
61+
"type": "string"
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"/worker": {
68+
"post": {
69+
"description": "parsing Json and registering worker",
70+
"consumes": [
71+
"application/json"
72+
],
73+
"produces": [
74+
"application/json"
75+
],
76+
"summary": "Register worker",
77+
"parameters": [
78+
{
79+
"description": "Worker data",
80+
"name": "worker",
81+
"in": "body",
82+
"required": true,
83+
"schema": {
84+
"$ref": "#/definitions/entity.Worker"
85+
}
86+
}
87+
],
88+
"responses": {
89+
"200": {
90+
"description": "OK",
91+
"schema": {
92+
"$ref": "#/definitions/entity.Worker"
93+
}
94+
},
95+
"400": {
96+
"description": "Invalid Json",
97+
"schema": {
98+
"type": "string"
99+
}
100+
},
101+
"405": {
102+
"description": "Only post method allowed",
103+
"schema": {
104+
"type": "string"
105+
}
106+
},
107+
"500": {
108+
"description": "internal error",
109+
"schema": {
110+
"type": "string"
111+
}
112+
}
113+
}
114+
}
115+
}
116+
},
117+
"definitions": {
118+
"entity.Job": {
119+
"type": "object",
120+
"properties": {
121+
"arrival_time": {
122+
"type": "string"
123+
},
124+
"execution_time": {
125+
"type": "integer"
126+
},
127+
"id": {
128+
"type": "string"
129+
},
130+
"name": {
131+
"type": "string"
132+
},
133+
"task_priority": {
134+
"type": "integer"
135+
}
136+
}
137+
},
138+
"entity.Worker": {
139+
"type": "object",
140+
"properties": {
141+
"worker_id": {
142+
"type": "string"
143+
}
144+
}
145+
}
146+
}
147+
}`
148+
149+
// SwaggerInfo holds exported Swagger Info so clients can modify it
150+
var SwaggerInfo = &swag.Spec{
151+
Version: "",
152+
Host: "",
153+
BasePath: "",
154+
Schemes: []string{},
155+
Title: "",
156+
Description: "",
157+
InfoInstanceName: "swagger",
158+
SwaggerTemplate: docTemplate,
159+
LeftDelim: "{{",
160+
RightDelim: "}}",
161+
}
162+
163+
func init() {
164+
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
165+
}

backend/docs/swagger.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"contact": {}
5+
},
6+
"paths": {
7+
"/job": {
8+
"post": {
9+
"description": "parsing Json and pushing job",
10+
"consumes": [
11+
"application/json"
12+
],
13+
"produces": [
14+
"application/json"
15+
],
16+
"summary": "Accept Job",
17+
"parameters": [
18+
{
19+
"description": "Job data",
20+
"name": "job",
21+
"in": "body",
22+
"required": true,
23+
"schema": {
24+
"$ref": "#/definitions/entity.Job"
25+
}
26+
}
27+
],
28+
"responses": {
29+
"200": {
30+
"description": "OK",
31+
"schema": {
32+
"$ref": "#/definitions/entity.Job"
33+
}
34+
},
35+
"400": {
36+
"description": "Invalid Json",
37+
"schema": {
38+
"type": "string"
39+
}
40+
},
41+
"405": {
42+
"description": "Only post method allowed",
43+
"schema": {
44+
"type": "string"
45+
}
46+
},
47+
"500": {
48+
"description": "internal error",
49+
"schema": {
50+
"type": "string"
51+
}
52+
}
53+
}
54+
}
55+
},
56+
"/worker": {
57+
"post": {
58+
"description": "parsing Json and registering worker",
59+
"consumes": [
60+
"application/json"
61+
],
62+
"produces": [
63+
"application/json"
64+
],
65+
"summary": "Register worker",
66+
"parameters": [
67+
{
68+
"description": "Worker data",
69+
"name": "worker",
70+
"in": "body",
71+
"required": true,
72+
"schema": {
73+
"$ref": "#/definitions/entity.Worker"
74+
}
75+
}
76+
],
77+
"responses": {
78+
"200": {
79+
"description": "OK",
80+
"schema": {
81+
"$ref": "#/definitions/entity.Worker"
82+
}
83+
},
84+
"400": {
85+
"description": "Invalid Json",
86+
"schema": {
87+
"type": "string"
88+
}
89+
},
90+
"405": {
91+
"description": "Only post method allowed",
92+
"schema": {
93+
"type": "string"
94+
}
95+
},
96+
"500": {
97+
"description": "internal error",
98+
"schema": {
99+
"type": "string"
100+
}
101+
}
102+
}
103+
}
104+
}
105+
},
106+
"definitions": {
107+
"entity.Job": {
108+
"type": "object",
109+
"properties": {
110+
"arrival_time": {
111+
"type": "string"
112+
},
113+
"execution_time": {
114+
"type": "integer"
115+
},
116+
"id": {
117+
"type": "string"
118+
},
119+
"name": {
120+
"type": "string"
121+
},
122+
"task_priority": {
123+
"type": "integer"
124+
}
125+
}
126+
},
127+
"entity.Worker": {
128+
"type": "object",
129+
"properties": {
130+
"worker_id": {
131+
"type": "string"
132+
}
133+
}
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)