Jason Coposky, Chief Technologist
The iRODS Plugin Architecture
iRODS provides 6 plugin interfaces
Anatomy of a Plugin
Example Code
git clone https://github.com/irods/contrib
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; imgObj.read(filePath); 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
msvc->add_operation(
"msiget_image_meta_impl",
"msiget_image_meta");
return msvc;
}
} // extern "C"
Building a microservice plugin
GCC = g++
INC=-I/usr/include/irods/ -I/usr/include/irods/boost/ -I/usr/include/ImageMagick
all: libmsiget_image_meta
libmsiget_image_meta:
${GCC} ${INC} -DRODS_SERVER -fPIC "-Wl,-E" -shared -g \
-Wno-deprecated -rdynamic -o $@.so $@.cpp -lMagick++
clean:
@rm -f ./*.so
Questions?