Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
git-svn-id: http://kazuho.31tools.com/svn/q4m/trunk@1 23330352-1942-0410-abcd-d9b8ebed9e9b
  • Loading branch information
kazuho committed Dec 25, 2007
0 parents commit ef96f1a
Show file tree
Hide file tree
Showing 13 changed files with 1,523 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see README
339 changes: 339 additions & 0 deletions COPYING

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.1 - Fri Dec 21 22:23:51 JST 2007
- initial release
1 change: 1 addition & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see README
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBDIRS= src
EXTRA_DIST= config/ac_mysql.m4
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please read the ChangeLog
75 changes: 75 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Q4M - a Message Queue for MySQL

Dec. 21 2007
Kazuho Oku
Cybozu Labs, Inc.


Q4M is a message queue that works as a pluggable storage engine of MySQL
5.1.

Since its development is still in very early alpha-stage, NEVER USE THE
SOFTWARE IN PRODUCTION ENVIRONMENT.


* LICENSE and COPYRIGHT

Please refer to each file. The engine was built from the Skeleton engine
and the copyright of the build scripts mostly belong to their authors.
Copyright of the source code of the queue engine belongs to Cybozu Labs,
Inc., and is licensed under GPLv2.


* LIMITATIONS

- table contents are not saved onto disk
- wait for updates
- no indexes support
- simplicity for speed
- is it neressary, when we can create any number of tables=queues?


* INSTALLATION

To install the software, follow the steps below.

% ./configure --with-mysql=<mysql-source-dir> --libdir=<mysql-lib-dir>
% make
% make install
% mysql -u root
> INSTALL PLUGIN queue SONAME 'libqueue_engine.so';
> CREATE FUNCTION queue_wait RETURN INT SONAME 'libqueue_engine.so';
> CREATE FUNCTION queue_end RETURN INT SONAME 'libqueue_engine.so';
> CREATE FUNCTION queue_abort RETURN INT SONAME 'libqueue_engine.so';

If you are installing Q4M against a debug build of MySQL, it might be
necessary to set the -DSAFE_MUTEX compile option.

% CFLAGS=-DSAFE_MUTEX CXXFLAGS=-DSAFE_MUTEX ./configure ...


* USAGE

creating queues:
> CREATE TABLE my_queue (id INT UNSIGNED NOT NULL) ENGINE=queue;

sending messages to queue:
> INSERT INTO my_queue (id) values (2),(3),(4);

receiving messages from queue (shown in perl code):

while (1) {
# wait until any data becomes available
$dbh->do('select queue_wait("dbname.tblname")');
# receive data (only one row becomes ready at once)
if (my @ary = $dbh->selectrow_array('select * from tblname')) {
# process data
unless (process_row(@ary)) {
# abort if failed, return data to queue
$dbh->do('select queue_abort()');
last;
}
}
}
# tidy up
$dbh->do('select queue_end()');
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see README
25 changes: 25 additions & 0 deletions config/ac_mysql.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_SRC
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_SRC_TEST], [
AC_MSG_CHECKING(for mysql source code)
AC_ARG_WITH(mysql,
[[ --with-mysql[=mysql src directory]
Source requir to build engine.]],
[
if test -d "$withval/sql"; then
MYSQL_SRC="$i/mysql_config"
fi
AC_DEFINE([MYSQL_SRC], [1], [Source directory for MySQL])
MYSQL_INC="-I$withval/sql -I$withval/include -I$withval/regex -I$withval"
AC_MSG_RESULT(["$withval"])
],
[
AC_MSG_ERROR(["no mysql source provided"])
])
])

dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_SRC
dnl ---------------------------------------------------------------------------
35 changes: 35 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
dnl For Queue for MySQL - a mysql pluggable storage engine
AC_INIT(src/ha_queue.cc)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(src/queue_config.h)
AM_INIT_AUTOMAKE("q4m", 0.1)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)dnl

sinclude(config/ac_mysql.m4)
sinclude(config/ac_system.m4)
sinclude(config/dtrace.m4)

MYSQL_SRC_TEST
AC_SUBST(MYSQL_INC)

# We only support GCC and Sun's forte at the moment
if test "$GCC" = "yes"
then
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-rtti"
else
CFLAGS="-Xa -xstrconst -mt -D_FORTEC_ -fast -m64"
CXXFLAGS="$CXXFLAGS -noex -mt -D_FORTEC_ -fast -m64"
DTRACEFLAGS="-64"
fi

AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_HEADERS(limits.h syslimits.h)
AC_OUTPUT(Makefile src/Makefile)
11 changes: 11 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
EXTRA_DIST= ha_queue.h
INCLUDES= $(MYSQL_INC)
noinst_HEADER= ha_queue.h

lib_LTLIBRARIES= libqueue_engine.la
libqueue_engine_la_SOURCES= ha_queue.cc
libqueue_engine_la_LIBADD=

libqueue_engine_la_LDFLAGS= -module
libqueue_engine_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libqueue_engine_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
Loading

0 comments on commit ef96f1a

Please sign in to comment.