示例#1
0
文件: bus.py 项目: yahym/lightbus
class AuthApi(lightbus.Api):
    user_registered = lightbus.Event(parameters=("username", "email"))

    class Meta:
        name = "auth"

    def check_password(self, username, password):
        return username == "admin" and password == "secret"
示例#2
0
class ApiA(lightbus.Api):
    event_a = lightbus.Event()

    class Meta:
        name = "api_a"

    def rpc_a(self):
        return "A"
示例#3
0
class ApiB(lightbus.Api):
    event_b = lightbus.Event()

    class Meta:
        name = "api_b"

    def rpc_b(self):
        return "b"
示例#4
0
class BenchmarkApi(lightbus.Api):
    fire_me = lightbus.Event()

    class Meta:
        name = "benchmark"

    def call_me(self):
        return True
示例#5
0
文件: bus.py 项目: yahym/lightbus
class AuthApi(lightbus.Api):
    user_registered = lightbus.Event(parameters=(
        lightbus.Parameter("username", str),
        lightbus.Parameter("email", str),
        lightbus.Parameter("is_admin", bool, default=False),
    ))

    class Meta:
        name = "auth"

    def check_password(self, username: str, password: str) -> bool:
        return username == "admin" and password == "secret"
示例#6
0
class AnalyticsApi(lightbus.Api):
    page_view = lightbus.Event(
        parameters=(
            lightbus.Parameter("pk", int),
            lightbus.Parameter("viewed_at", datetime),
            lightbus.Parameter("url", str),
            lightbus.Parameter("user_agent", str),
        )
    )

    @uses_django_db
    def get_total(self, url: str) -> int:
        from lightbus_examples.ex06_django.example_app.models import PageView

        return PageView.objects.filter(url=url).count()

    class Meta:
        name = "analytics"
示例#7
0
    class ApiWithVersion(lightbus.Api):
        my_event = lightbus.Event()

        class Meta:
            name = "versioned_api"
            version = 5
示例#8
0
文件: bus.py 项目: yahym/lightbus
class StoreApi(lightbus.Api):
    page_view = lightbus.Event(parameters=("url",))

    class Meta:
        name = "store"
示例#9
0
    class MyApi(lightbus.Api):
        my_event = lightbus.Event()

        class Meta:
            name = "my_api"