Cocaine¶
What is Cocaine? It’s an open-source cloud platform enabling you to build your own PaaS clouds using simple yet effective dynamic components.
- Page on github: https://github.com/cocaine/cocaine-core
This documentation is for cocaine-framework-python.
- Page on PyPI: https://pypi.python.org/pypi/cocaine
- Repository: https://github.com/cocaine/cocaine-framework-python
- Cocaine-tools: https://github.com/cocaine/cocaine-tools
- Requires at least Python 2.6
More documentation¶
Packages¶
Package cocaine¶
-
exception
cocaine.exceptions.
ChokeEvent
-
exception
cocaine.exceptions.
CocaineError
-
exception
cocaine.exceptions.
DisconnectionError
(name)
-
exception
cocaine.exceptions.
InvalidApiVersion
(servicename, expected_version, got_version)
-
exception
cocaine.exceptions.
InvalidChunk
-
exception
cocaine.exceptions.
InvalidMessageType
(servicename, reason, code, category=999)
-
exception
cocaine.exceptions.
ServiceConnectionError
(message)
-
exception
cocaine.exceptions.
ServiceError
(servicename, reason, code, category=999)
Package cocaine.worker¶
-
class
cocaine.worker.worker.
NullTokenManager
-
class
cocaine.worker.worker.
TicketVendingMachineTokenManager
(name, ticket, interval, loop=None)
-
class
cocaine.worker.worker.
TokenManager
Represents authorization token manager interface which is responsible for fetching and updating auth tokens.
Authorization systems are too different to create tiny abstraction to unite them. Some of them supports token refreshing, some does not. Instead of creating such abstraction layer we explicitly ask Cocaine Runtime which type of auth plugin is currently installed to select the proper way for token handling.
-
exception
cocaine.worker.request.
RequestError
(code, reason)
Cocaine Framework API¶
Features¶
- Possibility to write cocaine workers
- Wide support of asynchronous event-driven usage
- Ready for usage with cloud services
- Lots of examples included
- Provided with cocaine-tools and embedded cocaine proxy
- PyPy support
Quick example¶
Here’s some extremely useful Cocaine app written in Python:
#!/usr/bin/env python
from cocaine.worker import Worker
from cocaine.logger import Logger
log = Logger()
def echo(request, response):
message = yield request.read()
log.debug('Message received: \'{0}\'. Sending it back ...'.format(message))
response.write(message)
response.close()
W = Worker()
W.run({
'ping': echo,
})