Move configuration changes to a common file

The config_runtime.h header contains functions that can be used to
manipulate the running configuration. Currently the header contains the
function to create, add, remove and destroy servers.
This commit is contained in:
Markus Makela
2016-11-22 15:18:04 +02:00
parent d309444540
commit 8ef99c9066
10 changed files with 295 additions and 179 deletions

View File

@ -0,0 +1,81 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file config_runtime.h - Functions for runtime configuration modifications
*/
#include <maxscale/cdefs.h>
#include <maxscale/filter.h>
#include <maxscale/monitor.h>
#include <maxscale/server.h>
#include <maxscale/service.h>
/**
* @brief Create a new server
*
* This function creates a new, persistent server by first allocating a new
* server and then storing the resulting configuration file on disk. This
* function should be used only from administrative interface modules and internal
* modules should use server_alloc() instead.
*
* @param name Server name
* @param address Network address
* @param port Network port
* @param protocol Protocol module name
* @param authenticator Authenticator module name
* @param options Options for the authenticator module
* @return True on success, false if an error occurred
*/
bool runtime_create_server(const char *name, const char *address,
const char *port, const char *protocol,
const char *authenticator, const char *options);
/**
* @brief Destroy a server
*
* This removes any created server configuration files and marks the server removed
* If the server is not in use.
*
* @param server Server to destroy
* @return True if server was destroyed
*/
bool runtime_destroy_server(SERVER *server);
/**
* @brief Link a server to an object
*
* This function links the server to another object. The target can be either
* a monitor or a service.
*
* @param server Server to link
* @param target The monitor or service where the server is added
* @return True if the object was found and the server was linked to it, false
* if no object matching @c target was found
*/
bool runtime_link_server(SERVER *server, const char *target);
/**
* @brief Unlink a server from an object
*
* This function unlinks the server from another object. The target can be either
* a monitor or a service.
*
* @param server Server to unlink
* @param target The monitor or service from which the server is removed
* @return True if the object was found and the server was unlinked from it, false
* if no object matching @c target was found
*/
bool runtime_unlink_server(SERVER *server, const char *target);

View File

@ -203,7 +203,7 @@ struct monitor
extern MONITOR *monitor_alloc(char *, char *);
extern void monitor_free(MONITOR *);
extern MONITOR *monitor_find(char *);
extern MONITOR *monitor_find(const char *);
extern void monitorAddServer(MONITOR *mon, SERVER *server);
extern void monitorRemoveServer(MONITOR *mon, SERVER *server);
extern void monitorAddUser(MONITOR *, char *, char *);

View File

@ -227,25 +227,20 @@ extern SERVER* server_alloc(const char *name, const char *address, unsigned shor
const char *auth_options);
/**
* @brief Create a new server
* @brief Find a server that can be reused
*
* This function creates a new, persistent server by first allocating a new
* server and then storing the resulting configuration file on disk. This
* function should be used only from administrative interface modules and internal
* modules should use server_alloc() instead.
* A server that has been destroyed will not be deleted but only deactivated.
*
* @param name Server name
* @param address Network address
* @param port Network port
* @param protocol Protocol module name
* @param authenticator Authenticator module name
* @param options Options for the authenticator module
* @return True on success, false if an error occurred
* @param name Name of the server
* @param protocol Protocol used by the server
* @param authenticator The authenticator module of the server
* @param auth_options Options for the authenticator
* @return Reusable SERVER or NULL if no servers matching the criteria were
* found
* @see runtime_create_server
*/
extern bool server_create(const char *name, const char *address, const char *port,
const char *protocol, const char *authenticator,
const char *options);
SERVER* server_find_destroyed(const char *name, const char *protocol,
const char *authenticator, const char *auth_options);
/**
* @brief Serialize a server to a file
*
@ -258,16 +253,6 @@ extern bool server_create(const char *name, const char *address, const char *por
*/
bool server_serialize(const SERVER *server);
/**
* @brief Destroy a server
*
* This removes any created server configuration files and marks the server removed
* If the server is not in use.
* @param server Server to destroy
* @return True if server was destroyed
*/
bool server_destroy(SERVER *server);
extern int server_free(SERVER *);
extern SERVER *server_find_by_unique_name(const char *name);
extern SERVER *server_find(char *, unsigned short);

View File

@ -190,7 +190,7 @@ typedef enum count_spec_t
extern SERVICE *service_alloc(const char *, const char *);
extern int service_free(SERVICE *);
extern SERVICE *service_find(char *);
extern SERVICE *service_find(const char *);
extern int service_isvalid(SERVICE *);
extern int serviceAddProtocol(SERVICE *service, char *name, char *protocol,
char *address, unsigned short port,