diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-18 04:10:12 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 04:10:12 +0000 |
| commit | 7b1ef9ad9ca541077f81d23e72075a83f41f3dd4 (patch) | |
| tree | 41b3949576d6771fd450a74a6ebe89d48d4212e6 /python-tqp.spec | |
| parent | 7f48cfff319cb44dfa7d98c76acd3f890aa670e2 (diff) | |
automatic import of python-tqp
Diffstat (limited to 'python-tqp.spec')
| -rw-r--r-- | python-tqp.spec | 270 |
1 files changed, 270 insertions, 0 deletions
diff --git a/python-tqp.spec b/python-tqp.spec new file mode 100644 index 0000000..080edab --- /dev/null +++ b/python-tqp.spec @@ -0,0 +1,270 @@ +%global _empty_manifest_terminate_build 0 +Name: python-tqp +Version: 0.5.1 +Release: 1 +Summary: An opinionated library for pub/sub over SQS and SNS +License: MIT +URL: https://github.com/4Catalyzer/tqp +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a9/33/a64749b84350b28763574918cfb781cb9ceb1dd1bb8578f55c503fb2a7a4/tqp-0.5.1.tar.gz +BuildArch: noarch + +Requires: python3-boto3 +Requires: python3-pytest +Requires: python3-fourmat +Requires: python3-pre-commit +Requires: python3-moto[server] +Requires: python3-boto3 + +%description +# TQP + +An opinionated library for pub/sub over SQS and SNS + +## Topic + +To publish on a topic: + +```py +topic = Topic('widgets--created') +topic.publish({'id': '123456'}) +``` + +## Topic Queue Poller + +To read from the topic: + +```py +poller = TopicQueuePoller('my_poller') + +@poller.handler('widgets--created') +def process_created_widget(item): + widget_id = item['id'] + print(f'Widget {widget_id} was created') + +poller.start() +``` + +### S3 notifications + +It is also possible to poll for s3 object notifications + +```py +@poller.s3_handler('my-bucket-name') +def process_file_created(msg): + print(msg) + # { + # 'event_name': 'ObjectCreated:Put', + # 'bucket_name': 'bespin-dev-consular21d51f71-11lpitfowdylc', + # 'object': { + # 'key': 'genome.fasta', + # 'size': 124, + # 'eTag': '5d9d04cd0b9d3b314d9bd622da06ab74', + # 'sequencer': '005FAD55883A198E97' + # }, + # } +``` + +### Flask + +A Flask binding is also provided: + +```py +poller = FlaskTopicQueuePoller('my_poller', app=flask_app) +``` + +When using the Flask poller, you can also specify how to format the logs: + +```py +# the argument (optional) is a function that takes the message payload as input and return a message identifier +poller.set_log_formatter(lambda payload: payload["message"].get("id", "<NO ID>")) +``` + + + + +%package -n python3-tqp +Summary: An opinionated library for pub/sub over SQS and SNS +Provides: python-tqp +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-tqp +# TQP + +An opinionated library for pub/sub over SQS and SNS + +## Topic + +To publish on a topic: + +```py +topic = Topic('widgets--created') +topic.publish({'id': '123456'}) +``` + +## Topic Queue Poller + +To read from the topic: + +```py +poller = TopicQueuePoller('my_poller') + +@poller.handler('widgets--created') +def process_created_widget(item): + widget_id = item['id'] + print(f'Widget {widget_id} was created') + +poller.start() +``` + +### S3 notifications + +It is also possible to poll for s3 object notifications + +```py +@poller.s3_handler('my-bucket-name') +def process_file_created(msg): + print(msg) + # { + # 'event_name': 'ObjectCreated:Put', + # 'bucket_name': 'bespin-dev-consular21d51f71-11lpitfowdylc', + # 'object': { + # 'key': 'genome.fasta', + # 'size': 124, + # 'eTag': '5d9d04cd0b9d3b314d9bd622da06ab74', + # 'sequencer': '005FAD55883A198E97' + # }, + # } +``` + +### Flask + +A Flask binding is also provided: + +```py +poller = FlaskTopicQueuePoller('my_poller', app=flask_app) +``` + +When using the Flask poller, you can also specify how to format the logs: + +```py +# the argument (optional) is a function that takes the message payload as input and return a message identifier +poller.set_log_formatter(lambda payload: payload["message"].get("id", "<NO ID>")) +``` + + + + +%package help +Summary: Development documents and examples for tqp +Provides: python3-tqp-doc +%description help +# TQP + +An opinionated library for pub/sub over SQS and SNS + +## Topic + +To publish on a topic: + +```py +topic = Topic('widgets--created') +topic.publish({'id': '123456'}) +``` + +## Topic Queue Poller + +To read from the topic: + +```py +poller = TopicQueuePoller('my_poller') + +@poller.handler('widgets--created') +def process_created_widget(item): + widget_id = item['id'] + print(f'Widget {widget_id} was created') + +poller.start() +``` + +### S3 notifications + +It is also possible to poll for s3 object notifications + +```py +@poller.s3_handler('my-bucket-name') +def process_file_created(msg): + print(msg) + # { + # 'event_name': 'ObjectCreated:Put', + # 'bucket_name': 'bespin-dev-consular21d51f71-11lpitfowdylc', + # 'object': { + # 'key': 'genome.fasta', + # 'size': 124, + # 'eTag': '5d9d04cd0b9d3b314d9bd622da06ab74', + # 'sequencer': '005FAD55883A198E97' + # }, + # } +``` + +### Flask + +A Flask binding is also provided: + +```py +poller = FlaskTopicQueuePoller('my_poller', app=flask_app) +``` + +When using the Flask poller, you can also specify how to format the logs: + +```py +# the argument (optional) is a function that takes the message payload as input and return a message identifier +poller.set_log_formatter(lambda payload: payload["message"].get("id", "<NO ID>")) +``` + + + + +%prep +%autosetup -n tqp-0.5.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-tqp -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.1-1 +- Package Spec generated |
