This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dockerflow callbacks for endpoint
Closes #1293
- Loading branch information
Showing
4 changed files
with
121 additions
and
1 deletion.
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
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,42 @@ | ||
"""DockerFlow endpoints""" | ||
|
||
import cyclone.web | ||
|
||
from twisted.internet.threads import deferToThread | ||
from autopush.web.base import BaseWebHandler | ||
|
||
|
||
class VersionHandler(BaseWebHandler): | ||
|
||
def _get_version(self): | ||
try: | ||
with open("version.json") as vers: | ||
self.write(vers.read()) | ||
except IOError as ex: | ||
# Trap the exception here because it can be converted to | ||
# a generic AssertionError failure, and context gets lost. | ||
self.log.error( | ||
"Could not display version.json file content {}".format( | ||
ex | ||
)) | ||
raise | ||
|
||
def _error(self, failure): | ||
failure.trap(AssertionError, IOError) | ||
self.set_status(500) | ||
self.write("") | ||
|
||
def get(self): | ||
d = deferToThread(self._get_version) | ||
d.addBoth(self.finish) | ||
d.addErrback(self._error) | ||
return d | ||
|
||
|
||
class LBHeartbeatHandler(BaseWebHandler): | ||
|
||
@cyclone.web.asynchronous | ||
def get(self): | ||
self.set_status(200) | ||
self.write("") | ||
self.finish() |
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,6 @@ | ||
{ | ||
"source" : "https://github.com/mozilla-services/autopush", | ||
"version": "devel", | ||
"commit" : "", | ||
"build" : "" | ||
} |