Skip to main content

No project description provided

Project description

This package contains modules related to ClientConfigBuilder - A utility class for building the PolywrapClient config.

PolywrapClientConfigBuilder Supports building configs using method chaining or imperatively.

Quickstart

Import

Import necessary modules

>>> from typing import cast
>>> from polywrap_client_config_builder import (
...     PolywrapClientConfigBuilder,
...     BuilderConfig,
...     BuildOptions,
... )
>>> from polywrap_core import WrapPackage, Uri, ClientConfig
>>> from polywrap_uri_resolvers import (
...     RedirectResolver,
...     InMemoryResolutionResultCache,
...     RecursiveResolver,
... )
>>> from polywrap_sys_config_bundle import sys_bundle
>>> from polywrap_web3_config_bundle import web3_bundle

Initialize

Initialize a PolywrapClientConfigBuilder using the constructor

>>> # start with a blank slate (typical usage)
>>> builder = PolywrapClientConfigBuilder()

Configure

Add client configuration with add, or flexibly mix and match builder configuration methods to add and remove configuration items.

Add multiple items to the configuration using the catch-all add method

>>> builder = builder.add(
...     BuilderConfig(
...         envs={},
...         interfaces={},
...         redirects={},
...         wrappers={},
...         packages={},
...         resolvers=[]
...     )
... )

Add or remove items by chaining method calls

>>> builder = (
...     builder
...     .set_package(Uri.from_str("wrap://plugin/package"), cast(WrapPackage, NotImplemented))
...     .remove_package(Uri.from_str("wrap://plugin/package"))
...     .set_packages(
...         {
...             Uri.from_str("wrap://plugin/http"): cast(WrapPackage, NotImplemented),
...             Uri.from_str("wrap://plugin/filesystem"): cast(WrapPackage, NotImplemented),
...         }
...     )
... )
>>> Uri.from_str("wrap://plugin/http") in builder.config.packages
True
>>> Uri.from_str("wrap://plugin/filesystem") in builder.config.packages
True
>>> Uri.from_str("wrap://plugin/package") in builder.config.packages
False

Configure using sys config bundle to fetch wraps from file-system, ipfs, wrapscan, or http server

>>> from polywrap_sys_config_bundle import sys_bundle
>>> builder = builder.add_bundle(sys_bundle)

Configure using web3 config bundle to fetch wraps from ens and any system URI

>>> from polywrap_web3_config_bundle import web3_bundle
>>> builder = builder.add_bundle(web3_bundle)

Build

Finally, build a ClientConfig to pass to the PolywrapClient constructor.

Accepted by the PolywrapClient

>>> config = builder.build()
>>> assert isinstance(config, ClientConfig)
>>> assert isinstance(config.resolver, RecursiveResolver)

Build with a custom cache

>>> config = builder.build(
...     BuildOptions(
...         resolution_result_cache=InMemoryResolutionResultCache()
...     )
... )
>>> assert isinstance(config, ClientConfig)
>>> assert isinstance(config.resolver, RecursiveResolver)

Or build with a custom resolver

>>> config = builder.build(
...     BuildOptions(
...         resolver=RedirectResolver(
...             from_uri=Uri.from_str("wrap://test/from"),
...             to_uri=Uri.from_str("wrap://test/to")
...         )
...     )
... )
>>> assert isinstance(config, ClientConfig)
>>> assert isinstance(config.resolver, RedirectResolver)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file polywrap_client_config_builder-0.1.0b6.tar.gz.

File metadata

File hashes

Hashes for polywrap_client_config_builder-0.1.0b6.tar.gz
Algorithm Hash digest
SHA256 3a56bb616757d404fb2d68d6bf77a76ddaa801914089e15360a930ea91590e9c
MD5 f1da851f8d787b1afebc8313a1cd839a
BLAKE2b-256 94bfbbb7aa00f9f0cbba2e139b2cb35c79e562d38c2dcdd5ac046ec1e2b72ee0

See more details on using hashes here.

Provenance

File details

Details for the file polywrap_client_config_builder-0.1.0b6-py3-none-any.whl.

File metadata

File hashes

Hashes for polywrap_client_config_builder-0.1.0b6-py3-none-any.whl
Algorithm Hash digest
SHA256 c7206daaf6e49f898755e21d7d7abb161a93f3a7756423a86c373e2192f79499
MD5 6db9005d63bf0fb90463fe694d160650
BLAKE2b-256 ad6e45ddbf03806187869ca078dd4222dfbe58695904a5b778a75614f4589823

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page