Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/archive-modules.sgml`
9f854406d6876efaf5ed3a72a13720cd64c1f34dea56edba00000001000008e0
 ArchiveCheckConfiguredCB check_configured_cb;
    ArchiveFileCB archive_file_cb;
    ArchiveShutdownCB shutdown_cb;
} ArchiveModuleCallbacks;
typedef const ArchiveModuleCallbacks *(*ArchiveModuleInit) (void);
</programlisting>

   Only the <function>archive_file_cb</function> callback is required.  The
   others are optional.
  </para>
 </sect1>

 <sect1 id="archive-module-callbacks">
  <title>Archive Module Callbacks</title>
  <para>
   The archive callbacks define the actual archiving behavior of the module.
   The server will call them as required to process each individual WAL file.
  </para>

  <sect2 id="archive-module-startup">
   <title>Startup Callback</title>
   <para>
    The <function>startup_cb</function> callback is called shortly after the
    module is loaded.  This callback can be used to perform any additional
    initialization required.  If the archive module has any state, it can use
    <structfield>state->private_data</structfield> to store it.

<programlisting>
typedef void (*ArchiveStartupCB) (ArchiveModuleState *state);
</programlisting>
   </para>
  </sect2>

  <sect2 id="archive-module-check">
   <title>Check Callback</title>
   <para>
    The <function>check_configured_cb</function> callback is called to determine
    whether the module is fully configured and ready to accept WAL files (e.g.,
    its configuration parameters are set to valid values).  If no
    <function>check_configured_cb</function> is defined, the server always
    assumes the module is configured.

<programlisting>
typedef bool (*ArchiveCheckConfiguredCB) (ArchiveModuleState *state);
</programlisting>

    If <literal>true</literal> is returned, the server will proceed with
    archiving the file by calling the <function>archive_file_cb</function>
    callback.  If <literal>false</literal> is returned, archiving will not
    proceed, and the archiver will emit the following message to the server log:
<screen>
WARNING:  archive_mode enabled, yet archiving is not configured
</screen>
    In the latter case, the server will periodically call this function, and
    archiving will proceed only when it returns <literal>true</literal>.
   </para>

   <note>
    <para>
     When returning <literal>false</literal>, it may be useful to append

Title: Archive Module Callbacks: Startup and Configuration Checks
Summary
This section details the startup and configuration check callbacks for PostgreSQL archive modules. The startup callback is executed upon module loading for initialization, utilizing state->private_data to store module state. The check callback determines if the module is fully configured to accept WAL files; a false return prevents archiving and generates a warning in the server log, with the function being periodically called until a true value is returned.