When a user-defined iteration callback decides to interrupt function mco_translog_iterate() it should return any non-success code. It is preferable to choose some unique code, for example MCO_ERR_LAST orMCO_ERR_LAST+1 or so on to be able detect the exact source of error. This gives the ability to separate 'native' possible errors of function mco_translog_iterate() form errors passed by the user-defined callback.Function mco_translog_iterate() takes the argument 'void*user_ctx' (which is a user context for user-defined callback). Any other information about what has happened inside the user-defined callback and why it has decided to stop iterating should be passed via this user context.
If the user-defined iteration callback returns a non-MCO_S_OK code, then function mco_translog_iterate() immediately disconnects from the pipe and stops, returning this error code. The pipe is still alive and can be utilized in future. If logging was started with option MCO_TRANSLOG_DYNAMIC_PIPE then the writer application (the logging source) continues its run and a new call to function mco_translog_iterate() can be invoked to utilize the pipe again.
If logging was not started with option MCO_TRANSLOG_DYNAMIC_PIPE it assumes that any problem on the reader's side brakes logging. Then the writer application (logging source) gets error MCO_E_TL_PIPE_TERM to any attempt to commit next transaction. The logging procedure should be re-started and commits should be done again.
There are generally two scenarios for pipe usage:
Normal. The pipe strictly checks that the reader (mco_translog_iterate) is alive and brakes the logging if any error condition happens. This mode guarantees delivery of all logged transactions to the user-defined iteration procedure.
Dynamic pipe. Varying numbers of readers (the total count should be less or equal to number of pipes created) can connect to a the logging pipe and disconnect from it at any arbitrary moment. This mode guarantees delivery only of transactions logged while the function mco_translog_iterate() is called.