GitXplorerGitXplorer
j

pykka-injector

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b810babc94a1de84f23c5674e50c0087fcab6018

Update README.rst

jjstasiak committed 11 years ago
Unverified
5c09c2fe836eec12bd87511bf94c3cb7e510e65c

Make sample in the readme colorful

jjstasiak committed 11 years ago
Unverified
9f006a8302da882a3de06573829dddf78a9e323d

Tune metadata

jjstasiak committed 11 years ago
Unverified
2b3c0d9dcff7f3cfedfc0c5f5e5ae25232623c0f

Include tests in source distribution

jjstasiak committed 11 years ago
Unverified
89a1fe730d444f08f5cefc2f645ce5c4527ca63e

Change name

jjstasiak committed 11 years ago
Unverified
283e9ba2f2c9417f6284768e780d65a8006a685c

Fix version reading in setup

jjstasiak committed 11 years ago

README

The README file for this repository.

pykka-injector

.. image:: https://travis-ci.org/jstasiak/pykka-injector.png?branch=master :alt: Build status :target: https://travis-ci.org/jstasiak/pykka-injector

pykka-injector is a module uniting Injector <https://github.com/alecthomas/injector>_ (Dependency Injection framework) and Pykka <https://github.com/jodal/pykka>_ (Python implementation of the actor model). It's only purpose is to allow you to inject dependencies into Pykka Actors.

Works with:

  • CPython 2.x >= 2.6, 3.x >= 3.2
  • PyPy >= 1.9

Platform independent.

Usage example

.. code-block:: python

from injector import inject, Injector, InstanceProvider, Key, singleton
from pykka import ThreadingActor
from pykka_injector import ActorStarter

Config = Key('Config')

class MyActor(ThreadingActor):
    @inject(config=Config)
    def __init__(self, config, user):
        self.config = config
        self.user = user

def configure(binder):
    binder.bind(
        Config,
        to=InstanceProvider(dict(environment='dev')),
        scope=singleton,
    )

if __name__ == '__main__':
    injector = Injector(configure)
    starter = injector.get(ActorStarter)
    actor_ref = starter.start(MyActor, kwargs=dict(user='root'))

    actor_proxy = actor_ref.proxy()
    print(actor_proxy.config.get(), actor_proxy.user.get())

    actor_ref.stop()

Copyright

Copyright (C) 2013 Jakub Stasiak

This source code is licensed under MIT license, see LICENSE file for details.