Plugin architecture
How the platform hosts your code: plugins, versions, workers, instances, and properties.
Your goal
Understand the model before you write a plugin, so your first version is versioned, configurable, and deployable without surprises.
Expected outcome
You can say what a plugin, a version, a worker, and an instance each are - and you know which of them your code has to be aware of at runtime.
What a plugin is
A plugin is a package of code hosted by the platform, used to modify or extend the platform's features. It is a piece of logic encapsulated in a web service, and it can be developed in many languages.
The platform hosts and monitors it directly, which is what enables event-based triggering and fast access to the data. Once instantiated, a plugin listens on an HTTP port for requests coming from the platform, and depending on its type it must comply with a specific REST API.
The plugin types
Audience segment external feed
Sends data to a partner, either in server-side streams or by showing a pixel to users in the segment.
Display ad renderer
Customises the rendering of display ads.
-
Attribution engine
Customises the attribution of a marketing goal to different campaigns.
-
Integration batch
Manages data imports or exports by producing a batch of multiple items at once, one stage at a time.
-
ML Algorithm
Manages the calculation of predictions attached to a user, in an event-based manner. Used together with an ML Function.
-
The plugin objects
They are easiest to understand as a chain: you declare a plugin, publish a version of it, the platform runs workers for that version, and your users create instances configured through properties.
Plugin
The top-level declaration. It is attached to a specific organisation and has a specific type.
It is classified by a group_id and an artifact_id:
group_idis the name of the context, usually a reversed domain name such ascom.mediarithmics.creative.display. Lowercase alphanumeric characters, dots, hyphens, and underscores.artifact_idis the technical name of the plugin, such asimage-iframe. Lowercase alphanumeric characters, hyphens, and underscores - no dots.
Versions
A plugin supports multiple versions, each with its own codebase, layouts, properties, declarations, and configuration files, and several can be available at once. A version number is three digits with an optional suffix - 1.0.0, 1.2.0-rcl.
DRAFT
The initial state. Editable, but not usable until deployed.
DEPLOYING
For hosted containers: the platform is creating the container.
TESTING
Accessible to organisation administrators only. Can still be updated and tested in production, but users cannot create instances yet.
LIVE
Available to all users, and cannot be modified. Can be designated as the current_version, making it the default.
DECOMMISSIONED
Still visible, no longer usable. A version can only be decommissioned if no active instances exist in production.
ARCHIVED
Removed from the interface.
When to create a new version - when you need to edit properties, or when you want plugins already added by users to keep their existing behaviour.
You do not create a version to fix something in the code, or to change a delay in a configuration file. You do create one if the user should enter a new property value, or if your code changes so that existing instances should not use it.
Configuration files, external services, code, layouts
Properties
Creating a new version means redeclaring properties - changed or not - re-uploading configuration files, redeclaring external services and making sure they are enabled, redeploying the code with an updated version number in the build definition, and redeclaring the layouts.
Workers
To scale the processing of your plugin, the platform deploys its code several times on different servers and load-balances between them. Each of those deployments is a worker.
A new worker is created each time you create a version, or when scaling is needed. During that process the worker's /init route is called for initialisation and authentication, and it joins the other workers once its /status route responds ready.
Instances
An instance is created in the interface when a user configures a plugin for a use case. It links a plugin version, property values, and a context of execution - a segment, a channel, a datamart.
Configuring the same plugin for a different target does not necessarily create a new worker, but it always creates a new instance. Your code must therefore retrieve the instance to adapt to its context:
Properties
A version declares the properties available in its instances.
The possible origins:
PLUGIN_STATIC
Reserved for mandatory properties defined by mediarithmics. Every version must define name and provider. You can set their values, but change nothing else. Not writable, so the value is identical in every instance.
PLUGIN
Your custom properties, declared per version. Set writable: true to give a default value that instances can override, or false for a value shared by all instances.
INSTANCE
Properties specific to one instance of a version.
provider is usually mediarithmics for plugins made by mediarithmics, and the integrator or customer name otherwise.
Property types
STRING
{"value":"mystring"}
INT
{"value":12}
DOUBLE
{"value":12.45}
BOOLEAN
{"value":true}
URL
{"url": "https://example.com"}
ASSET (deprecated)
{"original_file_name": "cat.png", "asset_id": "1333", "file_path": "/1/public/assets/cat.png"}
DATA_FILE
{"uri": "", "last_modified": null}
ASSET_FILE
{"original_name": "cat.png", "asset_id": "1333", "path": "/1/public/assets/cat.png"}
ASSET_FOLDER
{"original_name": "cat.png", "asset_id": "1333", "path": "/1/public/assets/cat.png"}
AD_LAYOUT
{"id": "12", "version": "34"}
STYLE_SHEET
{"id": "12", "version": "34"}
PIXEL_TAG
{"value": "https://example.com/pixel"}
RECOMMENDER
{"recommender_id": "1"}
Some plugin types add their own property types, documented with that type.
Data files
A DATA_FILE property points to a file uploaded to the platform - usually JSON - containing information the plugin uses at runtime.
Use one instead of many properties when you want to:
update several versions or instances at once by uploading a new version of the file,
store a large number of advanced properties,
keep properties that only power users should touch out of the ordinary form.
Layouts
A layout lets you customise the new-instance and edit-instance screens: grouping properties into categories, and choosing the type of field representing each one. A layout is bound to a plugin version.
Controlling how hard a plugin is called
Some plugins call external providers with their own API limits, and not every plugin handles the errors that occur when those limits are hit. Throttlings reduce plugin calls before the limits are reached.
A throttling limits a given plugin version in these ways - you must define at least one:
max_qps
Calls per second. It can be decimal: 0.5 means at most one call every two seconds.
max_concurrency
Simultaneous calls.
timeout_ms
Maximum call duration - the call is killed beyond it.
Throttlings can be defined at these scopes: GLOBAL, CONTAINER, ORGANISATION, and DATAMART. For the organisation and datamart scopes, throttling_key holds the corresponding ID, and plugin_endpoint names the routes affected - for example /v1/user_segment_update. scope and plugin_endpoint are required.
Related pages
Last updated
Was this helpful?