mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
parent
18012a8d7a
commit
fddaed02d6
@ -75,11 +75,7 @@ public:
|
|||||||
kj::Promise<void> queue(QueueContext context) override {
|
kj::Promise<void> queue(QueueContext context) override {
|
||||||
std::string jobName = context.getParams().getJobName();
|
std::string jobName = context.getParams().getJobName();
|
||||||
LLOG(INFO, "RPC queue", jobName);
|
LLOG(INFO, "RPC queue", jobName);
|
||||||
ParamMap params;
|
LaminarCi::MethodResult result = laminar.queueJob(jobName, params(context.getParams().getParams()))
|
||||||
for(auto p : context.getParams().getParams()) {
|
|
||||||
params[p.getName().cStr()] = p.getValue().cStr();
|
|
||||||
}
|
|
||||||
LaminarCi::MethodResult result = laminar.queueJob(jobName, params)
|
|
||||||
? LaminarCi::MethodResult::SUCCESS
|
? LaminarCi::MethodResult::SUCCESS
|
||||||
: LaminarCi::MethodResult::FAILED;
|
: LaminarCi::MethodResult::FAILED;
|
||||||
context.getResults().setResult(result);
|
context.getResults().setResult(result);
|
||||||
@ -90,11 +86,7 @@ public:
|
|||||||
kj::Promise<void> start(StartContext context) override {
|
kj::Promise<void> start(StartContext context) override {
|
||||||
std::string jobName = context.getParams().getJobName();
|
std::string jobName = context.getParams().getJobName();
|
||||||
LLOG(INFO, "RPC start", jobName);
|
LLOG(INFO, "RPC start", jobName);
|
||||||
ParamMap params;
|
std::shared_ptr<Run> run = laminar.queueJob(jobName, params(context.getParams().getParams()));
|
||||||
for(auto p : context.getParams().getParams()) {
|
|
||||||
params[p.getName().cStr()] = p.getValue().cStr();
|
|
||||||
}
|
|
||||||
std::shared_ptr<Run> run = laminar.queueJob(jobName, params);
|
|
||||||
if(Run* r = run.get()) {
|
if(Run* r = run.get()) {
|
||||||
return r->whenStarted().then([context,r]() mutable {
|
return r->whenStarted().then([context,r]() mutable {
|
||||||
context.getResults().setResult(LaminarCi::MethodResult::SUCCESS);
|
context.getResults().setResult(LaminarCi::MethodResult::SUCCESS);
|
||||||
@ -110,11 +102,7 @@ public:
|
|||||||
kj::Promise<void> run(RunContext context) override {
|
kj::Promise<void> run(RunContext context) override {
|
||||||
std::string jobName = context.getParams().getJobName();
|
std::string jobName = context.getParams().getJobName();
|
||||||
LLOG(INFO, "RPC run", jobName);
|
LLOG(INFO, "RPC run", jobName);
|
||||||
ParamMap params;
|
std::shared_ptr<Run> run = laminar.queueJob(jobName, params(context.getParams().getParams()));
|
||||||
for(auto p : context.getParams().getParams()) {
|
|
||||||
params[p.getName().cStr()] = p.getValue().cStr();
|
|
||||||
}
|
|
||||||
std::shared_ptr<Run> run = laminar.queueJob(jobName, params);
|
|
||||||
if(const Run* r = run.get()) {
|
if(const Run* r = run.get()) {
|
||||||
runWaiters[r].emplace_back(kj::newPromiseAndFulfiller<RunState>());
|
runWaiters[r].emplace_back(kj::newPromiseAndFulfiller<RunState>());
|
||||||
return runWaiters[r].back().promise.then([context,run](RunState state) mutable {
|
return runWaiters[r].back().promise.then([context,run](RunState state) mutable {
|
||||||
@ -142,6 +130,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Helper to convert an RPC parameter list to a hash map
|
||||||
|
ParamMap params(const capnp::List<LaminarCi::JobParam>::Reader& paramReader) {
|
||||||
|
ParamMap res;
|
||||||
|
for(auto p : paramReader) {
|
||||||
|
res[p.getName().cStr()] = p.getValue().cStr();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Implements LaminarWaiter::complete
|
// Implements LaminarWaiter::complete
|
||||||
void complete(const Run* r) override {
|
void complete(const Run* r) override {
|
||||||
for(kj::PromiseFulfillerPair<RunState>& w : runWaiters[r])
|
for(kj::PromiseFulfillerPair<RunState>& w : runWaiters[r])
|
||||||
|
Loading…
Reference in New Issue
Block a user