Files
MaxScale/examples/examplefiltersession.cc
2020-10-14 09:15:46 +03:00

60 lines
1.5 KiB
C++

/*
* 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/bsl11.
*
* Change Date: 2024-10-14
*
* 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.
*/
// All log messages from this module are prefixed with this
#define MXS_MODULE_NAME "examplefilter"
#include "examplefiltersession.hh"
#include "examplefilter.hh"
ExampleFilterSession::ExampleFilterSession(MXS_SESSION* pSession, ExampleFilter& filter)
: mxs::FilterSession(pSession)
, m_filter(filter)
, m_session_id(pSession->ses_id)
{
}
ExampleFilterSession::~ExampleFilterSession()
{
}
// static
ExampleFilterSession* ExampleFilterSession::create(MXS_SESSION* pSession, ExampleFilter& filter)
{
return new ExampleFilterSession(pSession, filter);
}
void ExampleFilterSession::close()
{
// When the session is closed, report the numbers to the log.
MXS_NOTICE("Session %lu routed %i queries and %i replies.", m_session_id, m_queries, m_replies);
}
int ExampleFilterSession::routeQuery(GWBUF* pPacket)
{
m_queries++;
m_filter.query_seen();
// Pass the query forward.
return mxs::FilterSession::routeQuery(pPacket);
}
int ExampleFilterSession::clientReply(GWBUF* pPacket)
{
m_replies++;
m_filter.reply_seen();
// Pass the reply forward.
return mxs::FilterSession::clientReply(pPacket);
}