This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9962941
commit 33baf8c
Showing
2 changed files
with
103 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import ballerina/io; | ||
import celleryio/cellery; | ||
|
||
public function build(cellery:ImageName iName) returns error? { | ||
int salaryContainerPort = 8080; | ||
|
||
// Salary Component | ||
cellery:Component salaryComponent = { | ||
name: "salary", | ||
source: { | ||
image: "docker.io/celleryio/sampleapp-salary" | ||
}, | ||
ingresses: { | ||
SalaryAPI: <cellery:HttpApiIngress>{ | ||
port:salaryContainerPort, | ||
context: "payroll", | ||
definition: { | ||
resources: [ | ||
{ | ||
path: "salary", | ||
method: "GET" | ||
} | ||
] | ||
}, | ||
expose: "local" | ||
} | ||
}, | ||
probes: { | ||
liveness: { | ||
initialDelaySeconds: 30, | ||
kind: <cellery:TcpSocket>{ | ||
port:salaryContainerPort | ||
} | ||
} | ||
} | ||
}; | ||
|
||
// Employee Component | ||
int empPort = 8080; | ||
cellery:Component employeeComponent = { | ||
name: "employee", | ||
source: { | ||
image: "docker.io/celleryio/sampleapp-employee" | ||
}, | ||
ingresses: { | ||
employee: <cellery:HttpApiIngress>{ | ||
port:empPort, | ||
context: "employee", | ||
expose: "local" | ||
} | ||
}, | ||
probes: { | ||
liveness: { | ||
initialDelaySeconds: 30, | ||
kind: <cellery:TcpSocket>{ | ||
port:empPort | ||
} | ||
}, | ||
readiness: { | ||
initialDelaySeconds: 10, | ||
timeoutSeconds: 50, | ||
kind: <cellery:Exec>{ | ||
commands: ["bin", "bash", "-version"] | ||
} | ||
} | ||
}, | ||
envVars: { | ||
SALARY_HOST: { | ||
value: cellery:getHost(salaryComponent) | ||
} | ||
} | ||
}; | ||
|
||
cellery:CellImage employeeCell = { | ||
components: { | ||
empComp: employeeComponent, | ||
salaryComp: salaryComponent | ||
} | ||
}; | ||
|
||
return cellery:createImage(employeeCell, untaint iName); | ||
} | ||
|
||
|
||
public function run(cellery:ImageName iName, map<cellery:ImageName> instances) returns error? { | ||
cellery:CellImage employeeCell = check cellery:constructCellImage(untaint iName); | ||
return cellery:createInstance(employeeCell, iName, instances); | ||
} | ||
|
||
|
||
public function main(string action, cellery:ImageName iName, map<cellery:ImageName> instances) returns error? { | ||
return build(iName); | ||
} |