forked from ngetahun/py-multistream-select
-
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.
- Loading branch information
1 parent
86b0742
commit 64307ed
Showing
1 changed file
with
46 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,55 @@ | ||
|
||
# Multistream [![Build Status](https://api.travis-ci.org/dheatovwil/py-multistream-select.svg?branch=master)](https://travis-ci.org/dheatovwil/py-multistream-select) [![codecov](https://codecov.io/gh/dheatovwil/py-multistream-select/branch/master/graph/badge.svg)](https://codecov.io/gh/dheatovwil/py-multistream-select) | ||
# py-multistream-select | ||
|
||
[![Travis CI](https://api.travis-ci.org/dheatovwil/py-multistream-select.svg?branch=master)](https://travis-ci.org/dheatovwil/py-multistream-select) | ||
[![codecov.io](https://codecov.io/gh/dheatovwil/py-multistream-select/branch/master/graph/badge.svg)](https://codecov.io/gh/dheatovwil/py-multistream-select) | ||
|
||
This repository contains the python implementation of the [multistream-select](https://github.com/multiformats/multistream) protocol. | ||
> an implementation of the multistream protocol in python | ||
## Getting started | ||
## Table of Contents | ||
|
||
## Running the tests | ||
This project uses [pytest](https://docs.pytest.org/en/latest/). | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
|
||
On OSX, running `python -m pytest` runs all the tests. Amongst known issues, pytest might throw an `ImportError` if it cannot pull in the right libraries included in the test files. Try installing the library itself in debug mode using `pip install -e .` as it will then add `py-multistream-select` to your `PYTHONPATH`. | ||
## Install | ||
|
||
## Contributing | ||
|
||
`py-multistream-select` is a standard PyPI module which can be installed with: | ||
|
||
```sh | ||
pip install multistream-select | ||
``` | ||
|
||
## Usage | ||
|
||
### Example | ||
```python | ||
from multistream_select.multiselect import Multiselect | ||
from multistream_select.multiselect_client import MultiselectClient | ||
|
||
async def client_get_protocol(host_info): | ||
protocols = [ '/cats', '/dogs' ] | ||
stream = func_to_create_stream(host_info) | ||
client = MultiselectClient() | ||
return selected_protocol = await client.select_one_of(protocols, stream) | ||
|
||
async def host_get_protocol(handlers): | ||
stream = func_to_create_stream() | ||
host = Multiselect() | ||
for protocol in handlers: | ||
host.add_handler(protocol, handlers[protocol]) | ||
return host.negotiate(stream) | ||
``` | ||
|
||
## Contribute | ||
|
||
Contributions welcome. Please check out [the issues](https://github.com/dheatovwil/py-multistream-select/issues). | ||
|
||
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). | ||
|
||
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. | ||
|
||
## License | ||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |