Compare commits
No commits in common. "4d5a4d44bd80a740173bc7d32f30b5a9aaf510e7" and "2fbac213c7e2f095e64855c04ad1a2e27eaed7ca" have entirely different histories.
4d5a4d44bd
...
2fbac213c7
1
.gitignore
vendored
1
.gitignore
vendored
@ -119,4 +119,3 @@ GitHub.sublime-settings
|
|||||||
.history
|
.history
|
||||||
|
|
||||||
*pb2*
|
*pb2*
|
||||||
schemas
|
|
||||||
|
4
Makefile
4
Makefile
@ -1,6 +1,4 @@
|
|||||||
gen:
|
gen:
|
||||||
curl https://platform.sprinthub.ru/generator >> generator.py
|
python -m grpc_tools.protoc --proto_path schemas --python_out=. --pyi_out=. --grpc_python_out=. ./schemas/tasks.proto
|
||||||
python generator.py
|
|
||||||
rm generator.py
|
|
||||||
run:
|
run:
|
||||||
python ./server.py
|
python ./server.py
|
40
schemas/tasks.proto
Normal file
40
schemas/tasks.proto
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package queues;
|
||||||
|
|
||||||
|
import "google/protobuf/struct.proto";
|
||||||
|
|
||||||
|
service Tasks {
|
||||||
|
rpc Put (PutRequest) returns (EmptyResponse) {}
|
||||||
|
|
||||||
|
rpc Take (TakeRequest) returns (TakeResponse) {}
|
||||||
|
|
||||||
|
rpc Finish (FinishRequest) returns (EmptyResponse) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
message Task {
|
||||||
|
string id = 1;
|
||||||
|
int64 attempt = 2;
|
||||||
|
google.protobuf.Struct payload = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PutRequest {
|
||||||
|
string queue = 1;
|
||||||
|
int64 seconds_to_execute = 2;
|
||||||
|
optional int64 delay = 3;
|
||||||
|
google.protobuf.Struct payload = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TakeRequest {
|
||||||
|
string queue = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FinishRequest {
|
||||||
|
string id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmptyResponse {}
|
||||||
|
|
||||||
|
message TakeResponse {
|
||||||
|
optional Task task = 1;
|
||||||
|
}
|
@ -3,8 +3,8 @@ import datetime
|
|||||||
import grpc
|
import grpc
|
||||||
import bson
|
import bson
|
||||||
|
|
||||||
from queues import tasks_pb2
|
import tasks_pb2
|
||||||
from queues import tasks_pb2_grpc
|
import tasks_pb2_grpc
|
||||||
|
|
||||||
from utils import time
|
from utils import time
|
||||||
from storage.mongo import tasks
|
from storage.mongo import tasks
|
||||||
|
Loading…
Reference in New Issue
Block a user