Implementation

How to implement a Motator Binary?

Implementation

To implement source motators, it is required to implement an interface, implementing that interface is what allows the developer to build what we call a Motator Binary.

The Motator Binary primarily responsibility is to mutate a given value into a new value using a set of predefined rules or configuration.

type MotatorBinary interface {
	MutateValue(
		ctx context.Context, fieldValue string, fieldType field.TypeEnum, config map[string]string) (string, error)

	GetConfigOptions() syncmanstructs.ConfigOptions

	GetMotatorBinaryDetails() elements.MotatorBinaryDetails
}

The interface is divided in 2 main categories, mutation of the value and configuration.

  • MutateValue: This is the main method of a Motator Binary and allows mutating a given field value into a new value using the given and optional configuration.

  • Configuration methods:

    • GetConfigOption: Provides to Impulse the list of supported options the Motator Binary supports, these options are filled when the Sync Job is created and is passed as parameter in all the interface methods.

    • GetMotatorBinaryDetails: The motator details are the details for the Motator Binary, like unique ID, name, description, etc.

ImpulseSync Config Options

There are a number of config option keys that are set by ImpulseSync for use in the manipulator. These options should not be options set in the manipulator's individual config.

  • destinationEndpointId

    • The destination endpoint ID the content is being delivered to.

    • When manipulator is applied in write (prior to saving to diesel), there is no destination endpoint ID value.

  • sourceEndpointId

    • The source endpoint ID the content was picked up from.

  • jobSourceContentType

    • The source content type set for the job.

  • sourceParentContentId

    • The parent content id of the motation object from the source (pre id map).

  • mappedParentContentId

    • The mapped parent content id of the motation object (post id map).

  • contentMotationObject

    • The entire content motation object. Used to set up liquid engine.

  • definitionMotationObject

    • The entire definition motation object. Used to set up liquid engine.

  • applyToLanguages

    • A comma separated list of language IDs used by the motator-service to handle updating selected language(s) for manipulator's implementing mutateValue or addReplace functions.

Last updated