Copyright | (c) Winterland 2016 |
---|---|
License | BSD |
Maintainer | drkoster@qq.com |
Stability | experimental |
Portability | PORTABLE |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provide tools for binlog listening and row based binlog decoding.
Synopsis
- type SlaveID = Word32
- data BinLogTracker = BinLogTracker {
- btFileName :: !ByteString
- btNextPos :: !Word32
- registerPesudoSlave :: MySQLConn -> SlaveID -> IO OK
- dumpBinLog :: MySQLConn -> SlaveID -> BinLogTracker -> Bool -> IO (FormatDescription, IORef ByteString, InputStream BinLogPacket)
- data RowBinLogEvent
- decodeRowBinLogEvent :: (FormatDescription, IORef ByteString, InputStream BinLogPacket) -> IO (InputStream RowBinLogEvent)
- getLastBinLogTracker :: MySQLConn -> IO (Maybe BinLogTracker)
- isCheckSumEnabled :: MySQLConn -> IO Bool
- isSemiSyncEnabled :: MySQLConn -> IO Bool
- module Database.MySQL.BinLogProtocol.BinLogEvent
- module Database.MySQL.BinLogProtocol.BinLogValue
- module Database.MySQL.BinLogProtocol.BinLogMeta
binlog utilities
data BinLogTracker Source #
binlog filename and position to start listening.
BinLogTracker | |
|
Instances
Generic BinLogTracker Source # | |
Defined in Database.MySQL.BinLog type Rep BinLogTracker :: Type -> Type # from :: BinLogTracker -> Rep BinLogTracker x # to :: Rep BinLogTracker x -> BinLogTracker # | |
Show BinLogTracker Source # | |
Defined in Database.MySQL.BinLog showsPrec :: Int -> BinLogTracker -> ShowS # show :: BinLogTracker -> String # showList :: [BinLogTracker] -> ShowS # | |
Eq BinLogTracker Source # | |
Defined in Database.MySQL.BinLog (==) :: BinLogTracker -> BinLogTracker -> Bool # (/=) :: BinLogTracker -> BinLogTracker -> Bool # | |
type Rep BinLogTracker Source # | |
Defined in Database.MySQL.BinLog type Rep BinLogTracker = D1 ('MetaData "BinLogTracker" "Database.MySQL.BinLog" "mysql-haskell-1.1.5-Lci34tIS5e1Py7iUMs9yW" 'False) (C1 ('MetaCons "BinLogTracker" 'PrefixI 'True) (S1 ('MetaSel ('Just "btFileName") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "btNextPos") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32))) |
registerPesudoSlave :: MySQLConn -> SlaveID -> IO OK Source #
Register a pesudo slave to master, although MySQL document suggests you should call this
before calling dumpBinLog
, but it seems it's not really necessary.
:: MySQLConn | connection to be listened |
-> SlaveID | a number for our pesudo slave. |
-> BinLogTracker | binlog position |
-> Bool | if master support semi-ack, do we want to enable it? if master doesn't support, this parameter will be ignored. |
-> IO (FormatDescription, IORef ByteString, InputStream BinLogPacket) |
|
Setup binlog listening on given connection, during listening
the connection CAN NOT be used to do query, or an UnconsumedResultSet
will be thrown.
data RowBinLogEvent Source #
Row based binlog event type.
It's recommended to enable row query event before dumpBinLog
, so that you can get
RowQueryEvent
in row based binlog(it's important for detect a table change for example),
more information please refer sysvar_binlog_rows_query_log_events
A BinLogTracker
is included so that you can roll up your own HA solutions,
for example, writing the tracker to zookeeper when you done with an event.
The first Word32
field is a timestamp present when this event is logged.
Instances
decodeRowBinLogEvent :: (FormatDescription, IORef ByteString, InputStream BinLogPacket) -> IO (InputStream RowBinLogEvent) Source #
decode row based event from BinLogPacket
stream.
helpers
getLastBinLogTracker :: MySQLConn -> IO (Maybe BinLogTracker) Source #
Get latest master's binlog filename and position.
isCheckSumEnabled :: MySQLConn -> IO Bool Source #
Return True if binlog_checksum = CRC32. Only for MySQL > 5.6
isSemiSyncEnabled :: MySQLConn -> IO Bool Source #
Return True if rpl_semi_sync_master_enabled = ON. Only for MySQL > 5.5