-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Imp conftest for sqs * Add skip if not config boto3 * Fix test case * Fix test * Support sqs adapter * Add support in readme * Add Architecture.png
- Loading branch information
Showing
7 changed files
with
222 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<mxfile host="65bd71144e"> | ||
<diagram id="mhvqekLvz7hUb_vLKXXU" name="第 1 页"> | ||
<mxGraphModel dx="615" dy="856" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"> | ||
<root> | ||
<mxCell id="0"/> | ||
<mxCell id="1" parent="0"/> | ||
<mxCell id="21" value="" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1"> | ||
<mxGeometry x="490" y="200" width="280" height="260" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="22" value="Cluster B" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1"> | ||
<mxGeometry x="560" y="376" width="70" height="30" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="17" value="" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1"> | ||
<mxGeometry x="70" y="180" width="280" height="260" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="11" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="6"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="9" value="" style="edgeStyle=none;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="13" target="5"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="12" value="Push" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="9"> | ||
<mxGeometry x="-0.0444" y="5" relative="1" as="geometry"> | ||
<mxPoint y="-5" as="offset"/> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="3" value="redis-cannal<br>stream-to-queue" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"> | ||
<mxGeometry x="590" y="260" width="160" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="5" value="Grobal Queue" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1"> | ||
<mxGeometry x="360" y="260" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="6" value="" style="sketch=0;aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/mscae/Cache_Redis_Product.svg;" vertex="1" parent="1"> | ||
<mxGeometry x="155" y="370" width="50" height="42" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="8" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="7" target="3"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="7" value="" style="sketch=0;aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/mscae/Cache_Redis_Product.svg;" vertex="1" parent="1"> | ||
<mxGeometry x="645" y="380" width="50" height="42" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="13" value="adapter" style="whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"> | ||
<mxGeometry x="560" y="235" width="50" height="110" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="10" value="Poll" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="5" target="16"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="2" value="redis-cannal<br>queue-to-stream" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"> | ||
<mxGeometry x="120" y="260" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="16" value="adapter" style="whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"> | ||
<mxGeometry x="230" y="235" width="50" height="110" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="18" value="Cluster A" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1"> | ||
<mxGeometry x="220" y="370" width="70" height="30" as="geometry"/> | ||
</mxCell> | ||
</root> | ||
</mxGraphModel> | ||
</diagram> | ||
</mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
threshold: 100% | ||
patch: | ||
default: | ||
threshold: 100% |
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,52 @@ | ||
import pytest | ||
|
||
from redis_canal.adapter.impl.sqs import SQSAdapter | ||
from redis_canal.models import Message | ||
|
||
|
||
@pytest.fixture | ||
def sqs_adapter(case_id): | ||
try: | ||
import boto3 | ||
|
||
sqs = boto3.client("sqs") | ||
except ImportError: | ||
pytest.skip("boto3 is not installed") | ||
except Exception: | ||
pytest.skip("boto3 is not configured") | ||
|
||
queue_name = f"redis-canal-test-{case_id}" | ||
try: | ||
queue_url = sqs.create_queue(QueueName=queue_name)["QueueUrl"] | ||
except sqs.exceptions.QueueAlreadyExists: | ||
pass | ||
except Exception: | ||
pytest.skip("boto3 is not configured") | ||
|
||
adapter = SQSAdapter( | ||
queue_url=queue_url, | ||
poll_time=1, | ||
poll_size=10, | ||
) | ||
yield adapter | ||
try: | ||
sqs.delete_queue(QueueUrl=queue_url) | ||
except sqs.exceptions.QueueDoesNotExist: | ||
pass | ||
|
||
|
||
async def test_sqs_adapter(sqs_adapter): | ||
message_input = Message( | ||
redis_key="test", | ||
message_id="123-345", | ||
message_content={"f1": "v1"}, | ||
) | ||
|
||
async def validate(message): | ||
assert message == message_input | ||
print("validated!") | ||
|
||
await sqs_adapter.emit(message_input) | ||
await sqs_adapter.poll( | ||
process_func=validate, | ||
) |