Developing Microservice Plugins

Jason Coposky, Chief Technologist

The iRODS Plugin Architecture

iRODS provides 6 plugin interfaces

  • Storage Resource
  • Authentication
  • Network
  • Database
  • Microservice

Anatomy of a Plugin

  • Built as a dynamic shared object
  • provides a plugin_factory method which instantiates the plugin object
  • contains a class derived from a plugin interface base class:
    • ​api
    • auth
    • network
    • resource
    • database
    • ms_table_entry
  • NOTE: microservices do not require a derived class, the factory can return an instance of ms_table_entry

Example Code

git clone


cd contrib/microservices/training_example/msiget_image_meta



Writing a microservice - part 1

  • The microservice must use C linkage
extern "C" {
  • Declare the microservice implementation as usual, following the parameters with the rule engine context
 int msiget_image_meta_impl(msParam_t* _in, msParam_t* _out, ruleExecInfo_t* rei) {
        using std::cout;
        using std::endl;
        using std::string;
        char *filePath = parseMspForStr( _in );
        if( !filePath ) {
            cout << "msiget_image_meta - null filePath parameter" << endl;
            return SYS_INVALID_INPUT_PARAM;

Writing a microservice - part 2

        InitializeMagick((const char*)0);
        Image imgObj;;
        std::stringstream metaData;
        metaData << "ImageDepth=" << imgObj.modulusDepth()
                 << "%Width=" << imgObj.columns()
                 << "%Height=" << imgObj.rows()
                 << "%CompressionType=" << convertCompressTypeToStr(imgObj.compressType())
                 << "%Format=" << imgObj.format() 
                 << "%Colorspace=" << convertColorSpaceTypeToStr(imgObj.colorSpace());
        fillStrInMsParam(_out, metaData.str().c_str());
        return 0;
    } // msi_get_image_meta_impl

The plugin factory

  • factory function requires C linkage and must follow the signature
    irods::ms_table_entry* plugin_factory() {
  • instantiate a table entry and pass it the number of parameters of the microservice - not including the rule engine context
            irods::ms_table_entry* msvc = new irods::ms_table_entry(2);
  • wire the microservice name to the name of the implementation and return the plugin
            return msvc;
    } // extern "C"

Building a microservice plugin

  • The irods-dev package is required to build plugins
GCC = g++
INC=-I/usr/include/irods/ -I/usr/include/irods/boost/ -I/usr/include/ImageMagick
all: libmsiget_image_meta
    ${GCC} ${INC} -DRODS_SERVER -fPIC "-Wl,-E" -shared -g \
        -Wno-deprecated -rdynamic -o $ $@.cpp -lMagick++
    @rm -f ./*.so


Developing Microservice Plugins

By jason coposky

Developing Microservice Plugins

An overview of how to write and build an iRODS microservice plugin

  • 1,459
Loading comments...

More from jason coposky