Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Commit

Permalink
Add new sample
Browse files Browse the repository at this point in the history
  • Loading branch information
anuruddhal authored and isurulucky committed Jun 26, 2019
1 parent 9962941 commit 33baf8c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 18 deletions.
28 changes: 10 additions & 18 deletions test-cases/employee-portal/cellery/employee/employee.bal
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ballerina/config;
import ballerina/io;
import ballerina/log;
import celleryio/cellery;

public function build(cellery:ImageName iName) returns error? {
Expand Down Expand Up @@ -32,39 +34,29 @@ public function build(cellery:ImageName iName) returns error? {
};

// Employee Component
int empPort = 8080;
cellery:Component employeeComponent = {
name: "employee",
source: {
image: "wso2cellery/sampleapp-employee:0.3.0"
},
ingresses: {
employee: <cellery:HttpApiIngress>{
port:empPort,
port: 8080,
context: "employee",
expose: "local",
definition: <cellery:ApiDefinition>cellery:readSwaggerFile("./resources/employee.swagger.json")
}
},
probes: {
liveness: {
initialDelaySeconds: 30,
kind: <cellery:TcpSocket>{
port:empPort
}
},
readiness: {
initialDelaySeconds: 10,
timeoutSeconds: 50,
kind: <cellery:Exec>{
commands: ["bin", "bash", "-c"]
}
}
},
envVars: {
SALARY_HOST: {
value: cellery:getHost(salaryComponent)
},
PORT: {
value: salaryContainerPort
}
},
labels: {
team: "HR"
}
};

Expand All @@ -82,4 +74,4 @@ public function build(cellery:ImageName iName) returns error? {
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);
}
}
93 changes: 93 additions & 0 deletions test-cases/probes/probes_build.bal
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);
}

0 comments on commit 33baf8c

Please sign in to comment.