改造:分布式调度
协议
protobuf3
syntax = "proto3";
import "google/api/annotations.proto";
message JobName {
string name = 1;
}
message Ignore {
}
message Job {
string name = 1;
string command = 2;
string cronExpr = 3;
}
message Rsp {
int32 retCode = 1;
string retMsg = 2;
}
message RspWithJob {
Job job = 1;
Rsp rsp = 2;
}
message RspWithJobList {
repeated Job jobList = 1;
Rsp rsp = 2;
}
message JobLog {
string jobName = 1;
string command = 2;
string err = 3;
string output = 4;
int64 planTime = 5;
int64 scheduleTime = 6;
int64 startTime = 7;
int64 endTime = 8;
}
message ListLogReq {
string name = 1;
int32 skip = 2;
int32 limit = 3;
}
message RspWithLogList {
repeated JobLog logList = 1;
Rsp rsp = 2;
}
message RspWithWorkerList {
repeated string workerList = 1;
Rsp rsp = 2;
}
service CronTab {
rpc Save (Job) returns (RspWithJob) {
option (google.api.http) = {
post: "/job/save"
body: "*"
};
};
rpc Delete (JobName) returns (RspWithJob) {
option (google.api.http) = {
post: "/job/delete"
body: "*"
};
};
rpc KillJob (JobName) returns (Rsp) {
option (google.api.http) = {
post: "/job/kill"
body: "*"
};
};
rpc ListJobs (Ignore) returns (RspWithJobList) {
option (google.api.http) = {
post: "/job/list"
body: "*"
};
};
rpc ListLogs (ListLogReq) returns (RspWithLogList) {
option (google.api.http) = {
post: "/job/log"
body: "*"
};
};
rpc ListWorks (Ignore) returns (RspWithWorkerList) {
option (google.api.http) = {
post: "/worker/list"
body: "*"
};
};
}使用gofast编译
编译报错
gRPC:实现接口
Main
认证:签名
提供Http接口
双向认证
Gateway:同时提供RPC和Http接口
安装
http
文档:基于Swagger
安装
生成
下载Swagger UI文件
Swagger UI文件将Swagger UI转换为Go源代码
Swagger UI转换为Go源代码转换
检查
Swagger UI文件服务器(对外提供服务)
Swagger UI文件服务器(对外提供服务)安装
编写main
测试
最后更新于