Mattermost, Inc.

Perform 2 plugin.API calls in a transaction

Hey guys,

I would like to know if there is a way to perform 2 or more API calls within a db transaction?
Or maybe a non-hack way to get access to MM supplier dbsql connection?

Or what would you suggest is a nice pattern to follow here… I would rather not have to overkill it with a coordinator or something similar to saga.

Thank you in advance,


@scastillo, there’s nothing built-in to do exactly what you’re asking. For key value writes, we do expose a KVCompareAndSet which can be used to guarantee atomic writes, but it’s not applicable to the general plugin API.

We are investigating a “non-hacky” approach to connecting directly to the database, recognizing the usual caveats that apply from exposing same. No ETA right now, but depending on your use case, it’s not entirely unreasonable to connect directly to the database using the credentials available from GetUnsanitizedConfig.