Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <devrel@syntropynet.com>.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <devrel@synternet.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -108,4 +108,4 @@ the community.
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version
[1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and
[2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md),
and was generated by [contributing-gen](https://github.com/bttger/contributing-gen).
and was generated by [contributing-gen](https://github.com/bttger/contributing-gen).
36 changes: 18 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- omit in toc -->
# Contributing to Syntropy Pubsub Python
# Contributing to Synternet Pubsub Python

First off, thanks for taking the time to contribute! ❤️

Expand Down Expand Up @@ -29,20 +29,20 @@ All types of contributions are encouraged and valued. See the [Table of Contents
## Code of Conduct

This project and everyone participating in it is governed by the
[Syntropy Pubsub Python Code of Conduct](https://github.com/SyntropyNet/pubsub-python/blob/master/CODE_OF_CONDUCT.md).
[Synternet Pubsub Python Code of Conduct](https://github.com/Synternet/pubsub-python/blob/master/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior
to <devrel@syntropynet.com>.
to <devrel@synternet.com>.


## I Have a Question

> If you want to ask a question, we assume that you have read the available [Documentation](https://docs.syntropynet.com/docs).
> If you want to ask a question, we assume that you have read the available [Documentation](https://docs.synternet.com/docs).

Before you ask a question, it is best to search for existing [Issues](https://github.com/SyntropyNet/pubsub-python/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
Before you ask a question, it is best to search for existing [Issues](https://github.com/Synternet/pubsub-python/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open an [Issue](https://github.com/SyntropyNet/pubsub-python/issues/new).
- Open an [Issue](https://github.com/Synternet/pubsub-python/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.

Expand All @@ -62,8 +62,8 @@ We will then take care of the issue as soon as possible.
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://docs.syntropynet.com/docs). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/SyntropyNet/pubsub-python/issues?q=label%3Abug).
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://docs.synternet.com/docs). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/Synternet/pubsub-python/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
Expand All @@ -75,12 +75,12 @@ A good bug report shouldn't leave others needing to chase you up for more inform
<!-- omit in toc -->
#### How Do I Submit a Good Bug Report?

> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <devops@syntropynet.com>.
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <devops@synternet.com>.


We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Open an [Issue](https://github.com/SyntropyNet/pubsub-python/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Open an [Issue](https://github.com/Synternet/pubsub-python/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
Expand All @@ -95,26 +95,26 @@ Once it's filed:

### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for Syntropy Pubsub Python, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
This section guides you through submitting an enhancement suggestion for Synternet Pubsub Python, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.

<!-- omit in toc -->
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation](https://docs.syntropynet.com/docs) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/SyntropyNet/pubsub-python/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Read the [documentation](https://docs.synternet.com/docs) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/Synternet/pubsub-python/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/SyntropyNet/pubsub-python/issues).
Enhancement suggestions are tracked as [GitHub issues](https://github.com/Synternet/pubsub-python/issues).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. <!-- this should only be included if the project has a GUI -->
- **Explain why this enhancement would be useful** to most Syntropy Pubsub Python users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
- **Explain why this enhancement would be useful** to most Synternet Pubsub Python users. You may also want to point out the other projects that solved it better and which could serve as inspiration.

<!-- You might want to create an issue template for enhancement suggestions that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->

Expand Down Expand Up @@ -313,11 +313,11 @@ Please review this pull request and provide any feedback or suggestions for impr

We welcome you to join our project team and be a part of our exciting journey in revolutionizing data availability. If you have any questions, ideas, or simply want to connect with us, we encourage you to reach out through any of the following channels:

- **Discord**: Join our vibrant community on Discord at [https://discord.com/invite/jqZur5S3KZ](https://discord.com/invite/jqZur5S3KZ). Engage in discussions, seek assistance, and collaborate with like-minded individuals.
- **Discord**: Join our vibrant community on Discord at [https://discord.com/invite/synternet](https://discord.com/invite/synternet). Engage in discussions, seek assistance, and collaborate with like-minded individuals.

- **Telegram**: Connect with us on Telegram at [https://t.me/SyntropyNet](https://t.me/SyntropyNet). Stay updated with the latest news, announcements, and interact with our team members and community.
- **Telegram**: Connect with us on Telegram at [https://t.me/Synternet](https://t.me/Synternet). Stay updated with the latest news, announcements, and interact with our team members and community.

- **Email**: If you prefer email communication, feel free to reach out to us at devrel@syntropynet.com. We're here to address your inquiries, provide support, and explore collaboration opportunities.
- **Email**: If you prefer email communication, feel free to reach out to us at devrel@synternet.com. We're here to address your inquiries, provide support, and explore collaboration opportunities.

We value your contributions and look forward to having you as a part of our project team. Together, we can shape the future of data availability and create innovative solutions that empower the Web3 ecosystem.

Expand Down
49 changes: 4 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,16 @@ pip install git+https://github.com/Synternet/pubsub-python.git

Before you begin using the Python SDK, make sure you have the necessary credentials and access tokens from the Synternet [Developer Portal](https://portal.synternet.com/) platform. These credentials will allow you to connect to the Data Layer and subscribe to or publish data streams.

More information available in [https://docs.synternet.com/docs](Synternet documentation).

## Examples

For detailed usage examples, please refer to the [examples directory](https://github.com/Synternet/pubsub-python/examples) in the repository. These examples cover various scenarios and demonstrate how to utilize the SDK's features effectively.
For detailed usage examples, please refer to the [examples directory](https://github.com/Synternet/pubsub-python/tree/main/examples) in the repository. These examples cover various scenarios and demonstrate how to utilize the SDK's features effectively.

The preferred authentication method is using an access token from the [developer portal](https://portal.synternet.com/).

```Text Python
import asyncio
import nats
import tempfile
import os

from helper import create_app_jwt

ACCESS_TOKEN = "EXAMPLE_ACCESS_TOKEN"

async def main():
jwt = create_app_jwt(ACCESS_TOKEN)

# Write the JWT to a temporary file with correct format
with tempfile.NamedTemporaryFile(mode='w+t', delete=False) as temp:
temp.write(jwt)
temp_path = temp.name

nc = await nats.connect("nats://127.0.0.1", user_credentials=temp_path)

async def message_handler(msg):
subject = msg.subject
data = msg.data.decode()
print("Received a message on '{subject}: {data}".format(
subject=subject, data=data))

await nc.subscribe("syntropy.bitcoin.tx", cb=message_handler)

# run infinitely
while True:
await asyncio.sleep(1)

# Terminate connection to NATS.
await nc.drain()

# Delete the temporary file
os.unlink(temp_path)

if __name__ == '__main__':
asyncio.run(main())
```

# Contributing
We welcome contributions from the community! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/Synternet/pubsub-python). We appreciate your feedback and collaboration in making this SDK even better.
We welcome contributions from the community! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/Synternet/pubsub-python). We appreciate your feedback and collaboration in making this SDK even better.

## Contribution Guidelines

Expand All @@ -82,7 +42,6 @@ To streamline the pull request process, we have provided a [Pull Request Templat

We appreciate your contributions and thank you for your support in making this project better!


# Support

If you encounter any difficulties or have questions regarding the Python SDK for Data Layer, please reach out to our support team at [Discord #developer-discussion](https://discord.com/channels/503896258881126401/1125658694399561738). We are here to assist you and ensure a smooth experience with our SDK.
Expand Down
19 changes: 19 additions & 0 deletions examples/publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import asyncio
import nats

# See https://docs.synternet.com/build/dl-access-points
NATS_URL = "nats://broker-eu-01.synternet.com"
STREAM_SUBJECT = "synternet.example.subject"

async def main():
nc = await nats.connect(NATS_URL, user_credentials="nats.creds")

for i in range(1000):
await nc.publish(STREAM_SUBJECT, (str(i) + "x ").encode('utf-8'))
await asyncio.sleep(1)

# Terminate connection to NATS.
await nc.drain()

if __name__ == '__main__':
asyncio.run(main())
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import asyncio
import nats

NATS_URL = "nats://127.0.0.1"
# See https://docs.synternet.com/build/dl-access-points
NATS_URL = "nats://broker-eu-01.synternet.com"
SUB_SUBJECT = "synternet.example.subject"
PUB_SUBJECT = "republisher.example.subject"

async def main():
sub_nc = await nats.connect(NATS_URL, user_credentials="subscriber_nats.creds")
Expand All @@ -12,9 +15,9 @@ async def message_handler(msg):
data = msg.data.decode()
print("Received a message on '{subject}: {data}".format(
subject=subject, data=data))
await pub_nc.publish("republisher.example.subject", msg.data)
await pub_nc.publish(PUB_SUBJECT, msg.data)

await sub_nc.subscribe("synternet.example.subject", cb=message_handler)
await sub_nc.subscribe(SUB_SUBJECT, cb=message_handler)

# run infinitely
while True:
Expand Down
9 changes: 6 additions & 3 deletions subscribe_with_seed.py → examples/subscribe_with_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

from helper import create_app_jwt

ACCESS_TOKEN = "EXAMPLE_ACCESS_TOKEN"
# See https://docs.synternet.com/build/dl-access-points
NATS_URL = "nats://broker-eu-01.synternet.com"
ACCESS_TOKEN = "ACCESS_TOKEN"
STREAM_SUBJECT = "synternet.example.subject"

async def main():
jwt = create_app_jwt(ACCESS_TOKEN)
Expand All @@ -15,15 +18,15 @@ async def main():
temp.write(jwt)
temp_path = temp.name

nc = await nats.connect("nats://127.0.0.1", user_credentials=temp_path)
nc = await nats.connect(NATS_URL, user_credentials=temp_path)

async def message_handler(msg):
subject = msg.subject
data = msg.data.decode()
print("Received a message on '{subject}: {data}".format(
subject=subject, data=data))

await nc.subscribe("synternet.example.subject", cb=message_handler)
await nc.subscribe(STREAM_SUBJECT, cb=message_handler)

# run infinitely
while True:
Expand Down
15 changes: 0 additions & 15 deletions publish.py

This file was deleted.