Skip to content

Commit 43a98a1

Browse files
Merge pull request #1174 from cicoyle/fix-jobs-api
Jobs API Clarity: Rename schedulerDaprHttpPort -> jobServiceDaprHttpPort
2 parents 2f5a5d0 + a7d5808 commit 43a98a1

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

jobs/csharp/http/job-scheduler/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
};
1919

2020
var daprHost = Environment.GetEnvironmentVariable("DAPR_HOST") ?? "http://localhost";
21-
var schedulerDaprHttpPort = "6280";
21+
var jobServiceDaprHttpPort = "6280";
2222

2323
var httpClient = new HttpClient();
2424

@@ -48,7 +48,7 @@
4848

4949
async Task ScheduleJob(string jobName, object jobBody)
5050
{
51-
var reqURL = $"{daprHost}:{schedulerDaprHttpPort}/v1.0-alpha1/jobs/{jobName}";
51+
var reqURL = $"{daprHost}:{jobServiceDaprHttpPort}/v1.0-alpha1/jobs/{jobName}";
5252
var jsonBody = JsonSerializer.Serialize(jobBody);
5353
var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
5454

@@ -64,7 +64,7 @@ async Task ScheduleJob(string jobName, object jobBody)
6464

6565
async Task GetJobDetails(string jobName)
6666
{
67-
var reqURL = $"{daprHost}:{schedulerDaprHttpPort}/v1.0-alpha1/jobs/{jobName}";
67+
var reqURL = $"{daprHost}:{jobServiceDaprHttpPort}/v1.0-alpha1/jobs/{jobName}";
6868

6969
var response = await httpClient.GetAsync(reqURL);
7070

jobs/go/http/job-scheduler/job-scheduler.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ func main() {
3535
daprHost = "http://localhost"
3636
}
3737

38-
schedulerDaprHttpPort := "6280"
38+
jobServiceDaprHttpPort := "6280"
3939

4040
client := http.Client{
4141
Timeout: 15 * time.Second,
4242
}
4343

4444
// Schedule a job using the Dapr Jobs API with short dueTime
4545
jobName := "R2-D2"
46-
reqURL := daprHost + ":" + schedulerDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
46+
reqURL := daprHost + ":" + jobServiceDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
4747

4848
req, err := http.NewRequest("POST", reqURL, strings.NewReader(r2d2JobBody))
4949
if err != nil {
@@ -71,7 +71,7 @@ func main() {
7171
// Schedule a job using the Dapr Jobs API with long dueTime
7272
jobName = "C-3PO"
7373

74-
reqURL = daprHost + ":" + schedulerDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
74+
reqURL = daprHost + ":" + jobServiceDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
7575

7676
req, err = http.NewRequest("POST", reqURL, strings.NewReader(c3poJobBody))
7777
if err != nil {
@@ -93,7 +93,7 @@ func main() {
9393

9494
// Gets a job using the Dapr Jobs API
9595
jobName = "C-3PO"
96-
reqURL = daprHost + ":" + schedulerDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
96+
reqURL = daprHost + ":" + jobServiceDaprHttpPort + "/v1.0-alpha1/jobs/" + jobName
9797

9898
res, err = http.Get(reqURL)
9999
if err != nil {

jobs/javascript/http/job-scheduler/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const r2d2JobBody = {
1313
dueTime: "15s",
1414
};
1515
const daprHost = process.env.DAPR_HOST || "http://localhost";
16-
const schedulerDaprHttpPort = "6280";
16+
const jobServiceDaprHttpPort = "6280";
1717

1818
async function main() {
1919
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -45,7 +45,7 @@ async function main() {
4545
}
4646

4747
async function scheduleJob(jobName, jobBody) {
48-
const reqURL = `${daprHost}:${schedulerDaprHttpPort}/v1.0-alpha1/jobs/${jobName}`;
48+
const reqURL = `${daprHost}:${jobServiceDaprHttpPort}/v1.0-alpha1/jobs/${jobName}`;
4949
const response = await fetch(reqURL, {
5050
method: "POST",
5151
headers: {
@@ -64,7 +64,7 @@ async function scheduleJob(jobName, jobBody) {
6464
}
6565

6666
async function getJobDetails(jobName) {
67-
const reqURL = `${daprHost}:${schedulerDaprHttpPort}/v1.0-alpha1/jobs/${jobName}`;
67+
const reqURL = `${daprHost}:${jobServiceDaprHttpPort}/v1.0-alpha1/jobs/${jobName}`;
6868
const response = await fetch(reqURL, {
6969
method: "GET",
7070
});

jobs/python/http/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ This quickstart includes two apps:
1616
- [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/)
1717
- [Initialized Dapr environment](https://docs.dapr.io/getting-started/install-dapr-selfhost/)
1818

19+
## Environment Variables
20+
21+
- `JOB_SERVICE_DAPR_HTTP_PORT`: The Dapr HTTP port of the job-service (default: 6280)
22+
- `DAPR_HOST`: The Dapr host address (default: http://localhost)
23+
1924
## Install dependencies
2025

2126
<!-- STEP

jobs/python/http/job-scheduler/app.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ def main():
5555
time.sleep(5)
5656

5757
dapr_host = os.getenv('DAPR_HOST', 'http://localhost')
58-
scheduler_dapr_http_port = os.getenv('SCHEDULER_DAPR_HTTP_PORT', '6280')
58+
job_service_dapr_http_port = os.getenv('JOB_SERVICE_DAPR_HTTP_PORT', '6280')
5959

6060
# Schedule R2-D2 job
61-
schedule_job(dapr_host, scheduler_dapr_http_port, "R2-D2", R2D2_JOB_BODY)
61+
schedule_job(dapr_host, job_service_dapr_http_port, "R2-D2", R2D2_JOB_BODY)
6262
time.sleep(5)
6363

6464
# Schedule C-3PO job
65-
schedule_job(dapr_host, scheduler_dapr_http_port, "C-3PO", C3PO_JOB_BODY)
65+
schedule_job(dapr_host, job_service_dapr_http_port, "C-3PO", C3PO_JOB_BODY)
6666
time.sleep(5)
6767

6868
# Get C-3PO job details
69-
get_job_details(dapr_host, scheduler_dapr_http_port, "C-3PO")
69+
get_job_details(dapr_host, job_service_dapr_http_port, "C-3PO")
7070
time.sleep(5)
7171

7272
if __name__ == "__main__":

0 commit comments

Comments
 (0)