codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * basebackup_target.h4 * Extensibility framework for adding base backup targets.5 *6 * Portions Copyright (c) 2010-2023, PostgreSQL Global Development Group7 *8 * src/include/backup/basebackup_target.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef BASEBACKUP_TARGET_H13#define BASEBACKUP_TARGET_H14 15#include "backup/basebackup_sink.h"16 17struct BaseBackupTargetHandle;18typedef struct BaseBackupTargetHandle BaseBackupTargetHandle;19 20/*21 * Extensions can call this function to create new backup targets.22 *23 * 'name' is the name of the new target.24 *25 * 'check_detail' is a function that accepts a target name and target detail26 * and either throws an error (if the target detail is not valid or some other27 * problem, such as a permissions issue, is detected) or returns a pointer to28 * the data that will be needed to create a bbsink implementing that target.29 * The second argument will be NULL if the TARGET_DETAIL option to the30 * BASE_BACKUP command was not specified.31 *32 * 'get_sink' is a function that creates the bbsink. The first argument33 * is the successor sink; the sink created by this function should always34 * forward to this sink. The second argument is the pointer returned by a35 * previous call to the 'check_detail' function.36 *37 * In practice, a user will type something like "pg_basebackup --target foo:bar38 * -Xfetch". That will cause the server to look for a backup target named39 * "foo". If one is found, the check_detail callback will be invoked for the40 * string "bar", and whatever that callback returns will be passed as the41 * second argument to the get_sink callback.42 */43extern void BaseBackupAddTarget(char *name,44 void *(*check_detail) (char *, char *),45 bbsink *(*get_sink) (bbsink *, void *));46 47/*48 * These functions are used by the core code to access base backup targets49 * added via BaseBackupAddTarget(). The core code will pass the TARGET and50 * TARGET_DETAIL strings obtained from the user to BaseBackupGetTargetHandle,51 * which will either throw an error (if the TARGET is not recognized or the52 * check_detail hook for that TARGET doesn't like the TARGET_DETAIL) or53 * return a BaseBackupTargetHandle object that can later be passed to54 * BaseBackupGetSink.55 *56 * BaseBackupGetSink constructs a bbsink implementing the desired target57 * using the BaseBackupTargetHandle and the successor bbsink. It does this58 * by arranging to call the get_sink() callback provided by the extension59 * that implements the base backup target.60 */61extern BaseBackupTargetHandle *BaseBackupGetTargetHandle(char *target,62 char *target_detail);63extern bbsink *BaseBackupGetSink(BaseBackupTargetHandle *handle,64 bbsink *next_sink);65 66#endif67 