# Enabling Dynamic Services

This page provides a guide to using the new Dynamic Services feature in Platform 8.

**Available from:** Platform 8

## Overview

Dynamic Services is a new feature in Platform 8 that enables adapters to configure Liberator and Transformer with routing rules at the time of peer connection.

For a more detailed overview, see the [Dynamic Services](../datasource/datasource-dynamic-services.md) feature overview.

## Converting a static data-service to a dynamic data-service

The steps in this section use the following basic deployment as a worked example:

**Static peer configuration and static data-service configuration**

```plantuml
[Liberator1\n<color:gray>192.168.1.100</color>] as Liberator1
[PricingAdapter1\n<color:gray>192.168.1.50</color>] as PricingAdapter1

PricingAdapter1 -right-> Liberator1

note bottom of Liberator1
<color:blue>~# Incoming peer connection</color>
add-peer
  remote-label PricingAdapter1
end-peer

add-data-service
    service-name PricingService
    include-pattern ^/FX
    add-source-group
        add-priority
            remote-label PricingAdapter1
        end-priority
    end-source-group
end-data-service
end note

note bottom of PricingAdapter1
<color:blue>~# Outgoing peer connection</color>
add-peer
  remote-label Liberator1
  addr 192.168.1.100
end-peer
end note
```

Follow the steps below:

1. In the Liberator configuration, remove the static `add-peer` and `add-data-service` configuration associated with the adapter PricingAdapter1:

   ```plantuml
   [Liberator1\n<color:gray>192.168.1.100</color>] as Liberator1
   [PricingAdapter1\n<color:gray>192.168.1.50</color>] as PricingAdapter1

   PricingAdapter1 -right-> Liberator1

   note bottom of Liberator1


   end note

   note bottom of PricingAdapter1
   <color:blue>~# Outgoing peer connection</color>
   add-peer
     remote-label Liberator1
     addr 192.168.1.100
   end-peer
   end note
   ```

   **💡 TIP**\
   If PricingAdapter1 is packaged as a Caplin Platform Blade, the Liberator configuration you need to remove will likely be in the `rttpd.conf` file in the blade.
2. In the Liberator’s rttpd.conf file, define an API key and grant the key at least the `ds-dynamic-service` privilege (see [`add-apikey`](../datasource/datasource-datasource-peers-configuration-part-2.md#add-apikey)):

   ```plantuml
   [Liberator1\n<color:gray>192.168.1.100</color>] as Liberator1
   [PricingAdapter1\n<color:gray>192.168.1.50</color>] as PricingAdapter1

   PricingAdapter1 -right-> Liberator1

   note bottom of Liberator1
   **add-apikey "f9912b266<color:blue>...</color>ea25e047" <color:gray><U+2926></color>**
       **"ds-connect,ds-dynamic-peer, <color:gray><U+2926></color>**
       **ds-dynamic-service,ds-dynamic-fields"**
   end note

   note bottom of PricingAdapter1
   <color:blue>~# Outgoing peer connection</color>
   add-peer
     remote-label Liberator1
     addr 192.168.1.100
   end-peer
   end note
   ```

   **❗ IMPORTANT**\
   If PricingAdapter1 is packaged as a Caplin Platform Blade, don’t accidentally put the API key definition above in the `rttpd.conf` file in the adapter blade. API key definitions belong in the Liberator’s own configuration.
3. In the PricingAdapter1 `datasource.conf` file, specify the API key in the `add-peer` configuration for the connection to Liberator1 (see [`add-peer::apikey`](datasource-datasource-peers-configuration-part-1.md)):

   ```plantuml
   [Liberator1\n<color:gray>192.168.1.100</color>] as Liberator1
   [PricingAdapter1\n<color:gray>192.168.1.50</color>] as PricingAdapter1

   PricingAdapter1 -right-> Liberator1

   note bottom of Liberator1
   add-apikey "f9912b266<color:blue>...</color>ea25e047" <color:gray><U+2926></color>
       "ds-connect,ds-dynamic-peer, <color:gray><U+2926></color>
       ds-dynamic-service,ds-dynamic-fields"
   end note

   note bottom of PricingAdapter1
   <color:blue>~# Outgoing peer connection</color>
   add-peer
     remote-label Liberator1
     addr 192.168.1.100
     **apikey "9702ff...029b491"**
   end-peer
   end note
   ```
4. In the PricingAdapter1 `datasource.conf` file, define the data-service that will be provided to Liberator1 at the time of peer connection (see [`add-provided-data-service`](../datasource/datasource-data-services-configuration.md#add-provided-data-service)):

   ```plantuml
   [Liberator1\n<color:gray>192.168.1.100</color>] as Liberator1
   [PricingAdapter1\n<color:gray>192.168.1.50</color>] as PricingAdapter1

   PricingAdapter1 -right-> Liberator1

   note bottom of Liberator1
   add-apikey "f9912b266<color:blue>...</color>ea25e047" <color:gray><U+2926></color>
       "ds-connect,ds-dynamic-peer, <color:gray><U+2926></color>
       ds-dynamic-service,ds-dynamic-fields"
   end note

   note bottom of PricingAdapter1
   <color:blue>~# Outgoing peer connection</color>
   add-peer
     remote-label Liberator1
     addr 192.168.1.100
     apikey "9702ff...029b491"
   end-peer

   **add-provided-data-service**
       **service-name PricingService**
       **apply-if-label ^Liberator[0-9]+**
       **include-pattern ^/FX**
       **remote-label-regex ^PricingAdapter[0-9]+**
   **end-provided-data-service**
   end note
   ```

---

**See also:**

* [`add-peer::apikey`](datasource-datasource-peers-configuration-part-1.md)
* [`add-apikey`](../datasource/datasource-datasource-peers-configuration-part-2.md#add-apikey)
* [`add-provided-data-service`](../datasource/datasource-data-services-configuration.md#add-provided-data-service)
