Skip to main content

Service operations

Share operational policy without hiding the protocol.

ServiceRuntime selects a source, reuses it, and applies common headers, retries, cancellation, telemetry, and error context. The resulting source still exposes its protocol-specific methods.

Optional runtime layer

Standardize the boring parts of service access.

Use the runtime when several services need the same transport and lifecycle behavior. Keep direct source APIs when the application needs precise control over one protocol.

Select

Detect or explicitly choose a compatible service loader.

Reuse

Cache resolved source instances for repeated URLs.

Operate

Apply headers, retries, abort signals, and telemetry consistently.

Explain

Attach operation and request context to service errors.

Detailed guide

ServiceRuntime details

The reference below covers registry scope, source caching, shared options, custom loaders, telemetry, and the persistent-cache boundary.

ServiceRuntime is an optional lifecycle wrapper for the OGC sources in @loaders.gl/ogc/wms. It selects a loader, caches the resulting source, and applies consistent request policy without hiding the source's protocol-specific methods.

Feature support​

CapabilitySupportBehavior
Service loader selection✅ SupportedUses URL detection or an explicit loader list
Source instance cache✅ SupportedRepeated URLs reuse the resolved source
Shared headers✅ SupportedApplied to runtime requests
Retries✅ SupportedConfigurable retry count around transient failures
Cancellation✅ SupportedAbort signals propagate to requests
Telemetry✅ SupportedEmits request phase, URL, timing, and error events
Consistent errors✅ SupportedServiceRequestError carries operation and request context
Custom loaders✅ SupportedSupply a narrowed or extended loader list
ArcGIS loaders✅ InjectableArcGIS sources live in @loaders.gl/arcgis, not the default OGC registry
Persistent HTTP cache❌ Not providedIntegrate through the fetch layer or application cache

Usage​

import {ServiceRuntime} from '@loaders.gl/ogc/wms';

const runtime = new ServiceRuntime({
headers: {Authorization: `Bearer ${token}`},
retries: 3,
onTelemetry: event => console.log(event.phase, event.url)
});

const source = runtime.getSource('https://example.com/geoserver/wms');
const metadata = await source.getMetadata();

The default registry includes WMS, WMTS, WFS, WCS, CSW, OGC API Features, Tiles, Coverages, and EDR. Applications can supply loaders to reduce bundle scope or inject additional source loaders.

When to use it​

Use ServiceRuntime when an application needs a uniform operational policy across many dynamic service endpoints. Use createDataSource() directly when the endpoint and protocol are known and the extra lifecycle policy is unnecessary.