StaticRoutingStrategy
Overview
The StaticRoutingStrategy
is the simplest routing strategy that always returns a single, pre-configured gateway URL. This strategy ignores any gateways provided by the GatewaysProvider
and is useful for scenarios where you want to force all requests to use a specific gateway.
How It Works
The strategy always returns the configured gateway, ignoring any provided gateway lists:
- Configure Gateway: Set a single gateway URL during initialization
- Ignore Provided Gateways: Any gateways from providers are ignored
- Return Static Gateway: Always return the same configured gateway
- Log Warnings: Warn when provided gateways are ignored
Configuration
Basic Usage
import { StaticRoutingStrategy } from '@ar.io/wayfinder-core'
const strategy = new StaticRoutingStrategy({
gateway: 'https://arweave.net',
})
With Custom Gateway
const strategy = new StaticRoutingStrategy({
gateway: 'https://my-custom-gateway.com',
})
// will always return the provided gateway
const selectedGateway = await strategy.selectGateway();
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
gateway | string | required | The gateway URL to always use |
logger | Logger | defaultLogger | Optional logger instance |
Related
- FastestPingRoutingStrategy: Network-based gateway discovery
- PreferredWithFallbackRoutingStrategy: Static gateway configuration
- RandomRoutingStrategy: Randomized gateway selection