Package: osmosis-streaming-driver
osmosis-streaming-driver💧 Osmosis Streaming Driver Implementationoceanprotocol.comTable of ContentsOverviewSetup with Barge (Recommended)Standalone Install (Alternative)Code StyleTestingIntegrationNew VersionLicenseOverviewThis Osmosis Driver demonstrates how to expand Brizo, and go beyond static data files. It enables it to download live data from Websocket streams. It achieves this through a proxy server, which is responsible for issuing access tokens.Introduction Video:SetupThese steps show how to get this driver up and running withBarge.Due to a technical limitation, this driver does not currently work with the standardosmosis-driver-interface. It relies on aforked version. This repo includes a script to extend the Brizo container with the custom interface and patch Barge (i.e. patch_barge.sh ).We also piggyback on Brizo's container, and start our proxy server alongside the Brizo service. By default we expose port 3580 for the proxy.Proxy Server SettingsIf you open./Dockerfile, you will see a section containing the Proxy Server configuration. It resembles some of the settings used by the Provider-py service.You may need to customize some of the following settings:#ENV PROXY_SERVER_HOSTNAME='myproxyhost.com'
#ENV PROXY_SERVER_TOKEN_EXPIRATION_MIN=2PROXY_SERVER_HOSTNAMEis used for generating signed URLs. Let us assume you have a WebSocket stream pointing towss://websocket-api-host.com/stream-1The proxy will generate a signed URL in the formathttp://<HOST>:<PORT>/proxy?token=1234f654By default,PORTis3580andHOSTis theeth0IP address. For our purposes, this is most likely the IP of the Provider Docker container. This IP may not be directly available to external consumers. You can use this property to overrideHOSTwhen generating the signed URL.PROXY_SERVER_TOKEN_EXPIRATION_MINis also involved in the process of generating signed URLs. It determines how long should a token be valid. By default this value is 2 minutes.Other settings, related to timeout, default port and number of workers, may also be overriden. However, it is recommended that you leave them at their default valuesInstallUnless you want to compile from source, you can just use Pippip3installosmosis-streaming-driverYou also need to configure the Osmosis interface to start using by creating a configuration file, for example~/.osmosis.json. Paste the following content inside the file:{"wss://":"streaming"}And append the following line to your environment setup file (e.g.~/.bashrc):exportOSMOSIS_PLUGIN_MAP="$HOME/.osmosis.json"Once you reload your terminal, you can instantiate it such as:fromosmosis_driver_interface.osmosisimportOsmosisurl="wss://stream.binance.com:9443/ws/bnbbtc@depth"osm=Osmosis(url)# the proper osmosis driver is loaded automatically to match the url# Resolve the urldownload_url=osm.data_plugin.generate_url(url)Code StyleInformation about our Python code style is documented in thepython-developer-guideand thepython-style-guide.TestingAutomatic tests are setup via Travis, executingtox.
Our tests use the pytest framework.IntegrationThis driver interface also includes integration tests, based on thesquid-jssetup.Please refer to theIntegration READMEfor instructions on how to run this test and requirements.New VersionThebumpversion.shscript helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.LicenseLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.