TargetAdapter

Implement this interface to allow your Adapter to receive records from a Valence Link. Once implemented, your Adapter will show up in Valence as a possible data target.

You can use getBatchSizeLimit to tell Valence the maximum number of records your Adapter can accept at once. Valence will make sure batches are broken down to this size.

Warning

It is a requirement that your target Adapter respects the Link setting for Testing Mode, which an admin user sets when they don’t want records to actually persist into the target system.

You will know if a Link run is in testing mode if the LinkContext testingMode boolean property is set to true. At a minimum, you can simply immediately return from pushRecords():

public void pushRecords(valence.LinkContext context, List<valence.RecordInFlight> records) {

        // don't send any data if this Link is running in testing mode
        if(context.testingMode == true) {
                return;
        }

If possible, it’s nice if you have a mechanism to do a trial push where you can test a write but roll back so that you can attach any errors or warnings to the RecordInFlight instances. Very few APIs support a mechanic like this, so we don’t expect it but it’s a nice to have.

Definition

/**
 * Implement this interface if your Adapter can receive records from Valence.
 */
global interface TargetAdapter extends Adapter {

        /**
         * Specify a limit for how many records your endpoint can receive in a single batch.
         *
         * @param context Information about this Link and the current execution of it.
         *
         * @return An upper bound on how many records Valence should put in each batch when sending records to your adapter.
         */
        Integer getBatchSizeLimit(LinkContext context);

        /**
         * Send records to the adapter. The size of the List will not exceed the value returned by getBatchSizeLimit().
         *
         * @param context Information about this Link and the current execution of it.
         * @param records Records that have been received from another system, processed, and are ready for delivery.
         */
        void pushRecords(LinkContext context, List<RecordInFlight> records);
}