Skip to content

Commit 09e1013

Browse files
author
Lars Solberg
committed
cleanup
1 parent 7b7e812 commit 09e1013

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

examples/docker-compose/redis/plugins/redisfun.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
from fastapi import APIRouter, Depends
22

3-
from opa.utils.redis import get_aioredis, get_walrus
4-
from opa.core.plugin import BasePlugin, get_component, get_redis, get_plugin_manager
3+
from opa.core.plugin import BasePlugin, get_component
4+
from opa.plugins.driver_redis import Walrus
55

66
router = APIRouter()
77

88

99
@router.get("/counter-async")
1010
async def counter_async(aioredis=Depends(get_component('aioredis')), key=None):
11-
key = key or 'incr-async'
12-
counter = await aioredis.incr(key)
11+
counter = await aioredis.instance.incr(key or 'incr-async')
1312
return f'Counter is {counter}'
1413

1514

1615
@router.get("/counter-sync")
17-
def counter_sync(walrus=Depends(get_component('walrus')), key=None):
18-
key = key or 'incr-sync'
19-
counter = walrus.incr(key)
16+
def counter_sync(walrus: Walrus = Depends(get_component('walrus')), key=None):
17+
counter = walrus.instance.incr(key or 'incr-sync')
2018
return f'Counter is {counter}'
2119

2220

2321
@router.get("/bloom")
2422
def check_bloom_filter(string: str, walrus=Depends(get_component('walrus'))):
25-
bf = walrus.bloom_filter('bf')
23+
bf = walrus.instance.bloom_filter('bf')
2624
return string in bf
2725

2826

2927
@router.post("/bloom")
3028
def add_bloom_filter(string: str, walrus=Depends(get_component('walrus'))):
3129
# Waiting for https://github.com/tiangolo/fastapi/issues/1018 to have plain/text input
3230
# Possible now, but not with generation of the openapi spec..
33-
bf = walrus.bloom_filter('bf')
31+
bf = walrus.instance.bloom_filter('bf')
3432
for i in string.split(' '):
3533
bf.add(i)
3634

0 commit comments

Comments
 (0)