Drizzled Public API Documentation

module.cc

00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2011 David Shrewsbury
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <config.h>
00022 #include <plugin/slave/replication_slave.h>
00023 #include <drizzled/plugin.h>
00024 #include <drizzled/configmake.h>   // for SYSCONFDIR
00025 #include <drizzled/module/option_map.h>
00026 #include <boost/program_options.hpp>
00027 #include <boost/filesystem.hpp>
00028 #include <string>
00029 
00030 using namespace drizzled;
00031 using namespace std;
00032 
00033 namespace po= boost::program_options;
00034 namespace fs= boost::filesystem;
00035 
00036 namespace slave
00037 {
00038 
00039 static const fs::path DEFAULT_SLAVE_CFG_FILE= SYSCONFDIR "/slave.cfg";
00040 
00041 static string slave_config;
00042 
00043 static int init(module::Context &context)
00044 {
00045   const module::option_map &vm= context.getOptions();
00046 
00047   ReplicationSlave *slave= new ReplicationSlave(vm["config-file"].as<string>());
00048   if (vm.count("max-commit-id"))
00049     slave->setMaxCommitId(vm["max-commit-id"].as<uint64_t>());
00050   context.add(slave);
00051   return 0;
00052 }
00053 
00054 static void init_options(drizzled::module::option_context &context)
00055 {
00056   context("config-file",
00057           po::value<string>()->default_value(DEFAULT_SLAVE_CFG_FILE.string()),
00058           N_("Path to the slave configuration file"));
00059   context("max-commit-id",
00060           po::value<uint64_t>(),
00061           N_("Value to use as the maximum commit ID stored on the slave"));
00062 }
00063 
00064 } /* namespace slave */
00065 
00066 DRIZZLE_DECLARE_PLUGIN
00067 {
00068   DRIZZLE_VERSION_ID,
00069   "slave",
00070   "1.0",
00071   "David Shrewsbury",
00072   "Implements Drizzle replication slave.",
00073   PLUGIN_LICENSE_GPL,
00074   slave::init,
00075   NULL,                  /* depends */
00076   slave::init_options    /* config options */
00077 }
00078 DRIZZLE_DECLARE_PLUGIN_END;