Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds jobs endpoint protected by masterKey #2560

Merged
merged 8 commits into from
Aug 30, 2016
Merged

Adds jobs endpoint protected by masterKey #2560

merged 8 commits into from
Aug 30, 2016

Conversation

flovilmart
Copy link
Contributor

@flovilmart flovilmart commented Aug 21, 2016

  • Let serve define jobs on the /jobs/:jobName endpoint
  • Leverage the functions API so anything that applies to function applied to job
  • in the request params, functionName is jobName for job
  • A _JobStatus object is created upon starting a Job, the response include in the headers X-Parse-Job-Status-Id
  • in the response object, message, success and error functions are exposed. Those functions update the _JobStatus object
  • Jobs are only accessible through masterKey (unlike functions)
  • Jobs need an external scheduler.
  • Jobs may be killed by your stack if they take up too much time (the connection timeout is bumped to 15 minutes to mimic parse.com)

adresses discussions from #398

@codecov-io
Copy link

codecov-io commented Aug 21, 2016

Current coverage is 92.08% (diff: 94.41%)

Merging #2560 into master will decrease coverage by 0.06%

@@             master      #2560   diff @@
==========================================
  Files            97         99     +2   
  Lines         11927      12112   +185   
  Methods        1454       1487    +33   
  Messages          0          0          
  Branches       1929       1949    +20   
==========================================
+ Hits          10990      11153   +163   
- Misses          937        959    +22   
  Partials          0          0          

Powered by Codecov. Last update 23e47f2...3a79fa3

@flovilmart
Copy link
Contributor Author

I'll go an extra step:

  1. Create a _JobStatus object when starting the job (see below)
  2. Response with X-Parse-Job-Status-Id header, containing the job ID
  3. Make job run asynchronous (calling the endpoint won't wait till the job finishes)
  4. Remove the timeout, so jobs can run longer
  5. Let the res.message() update the message property of the _JobStatus object
  6. Let res.success/res.error update the status of the job and report the completion date

_JobStatus

{
    "_id": "<10 chars ID>",
    "createdAt": {
        "$date": "" // creation date string
    },
    "jobName": "<jobName>",
    "description": "", // not used
    "source": "api", // always be API
    "status": "<running|succeeded|failed>",
    "message": "<last message>",
    "params": null, // params received when calling the job
    "expiresAt": null, // will be null as we don't schedule
    "finishedAt": {
        "$date": "" // completion date string
    }
}

@drew-gross what do you think?

@drew-gross
Copy link
Contributor

Code looks good, this will probably need an accompanying PR in docs, and ideally the dashboard as well.

@flovilmart
Copy link
Contributor Author

You mean in the wiki?

@drew-gross
Copy link
Contributor

@flovilmart
Copy link
Contributor Author

Alright! I'll work on it :)

@ghost
Copy link

ghost commented Aug 28, 2016

@flovilmart updated the pull request - view changes

@flovilmart
Copy link
Contributor Author

@ghost
Copy link

ghost commented Aug 28, 2016

@flovilmart updated the pull request - view changes

1 similar comment
@facebook-github-bot
Copy link

@flovilmart updated the pull request - view changes

@drew-gross
Copy link
Contributor

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants