Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="FormatDescriptionEvent"/>.
 /// </summary>
 public FormatDescriptionEvent(
     EventHeader header,
     int binlogVersion,
     string serverVersion,
     ChecksumType checksumType) : base(header)
 {
     BinlogVersion = binlogVersion;
     ServerVersion = serverVersion;
     ChecksumType  = checksumType;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="WriteRowsEvent"/>.
 /// </summary>
 public WriteRowsEvent(
     EventHeader header,
     long tableId,
     int flags,
     int columnsNumber,
     bool[] columnsPresent,
     IReadOnlyList <ColumnData> rows)
     : base(header)
 {
     TableId        = tableId;
     Flags          = flags;
     ColumnsNumber  = columnsNumber;
     ColumnsPresent = columnsPresent;
     Rows           = rows;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new <see cref="UpdateRowsEvent"/>.
 /// </summary>
 public UpdateRowsEvent(
     EventHeader header,
     long tableId,
     int flags,
     int columnsNumber,
     bool[] columnsPresentBeforeUpdate,
     bool[] columnsPresentAfterUpdate,
     IReadOnlyList <UpdateColumnData> rows)
     : base(header)
 {
     TableId       = tableId;
     Flags         = flags;
     ColumnsNumber = columnsNumber;
     ColumnsPresentBeforeUpdate = columnsPresentBeforeUpdate;
     ColumnsPresentAfterUpdate  = columnsPresentAfterUpdate;
     Rows = rows;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new <see cref="TableMapEvent"/>.
 /// </summary>
 public TableMapEvent(
     EventHeader header,
     long tableId,
     string databaseName,
     string tableName,
     byte[] columnTypes,
     int[] columnMetadata,
     bool[] nullBitmap,
     TableMetadata tableMetadata) : base(header)
 {
     TableId        = tableId;
     DatabaseName   = databaseName;
     TableName      = tableName;
     ColumnTypes    = columnTypes;
     ColumnMetadata = columnMetadata;
     NullBitmap     = nullBitmap;
     TableMetadata  = tableMetadata;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructs a <see cref="IBinlogEvent"/> from packet buffer.
        /// </summary>
        public virtual IBinlogEvent DeserializeEvent(ref PacketReader reader)
        {
            var eventHeader = new EventHeader(ref reader);

            // Consider verifying checksum
            // ChecksumType.Verify(eventBuffer, checksumBuffer);
            reader.SliceFromEnd(ChecksumStrategy.Length);

            IBinlogEvent binlogEvent = null;

            if (EventParsers.TryGetValue(eventHeader.EventType, out var eventParser))
            {
                binlogEvent = eventParser.ParseEvent(eventHeader, ref reader);
            }
            else
            {
                binlogEvent = new UnknownEvent(eventHeader);
            }

            if (binlogEvent is FormatDescriptionEvent formatEvent)
            {
                ChecksumStrategy = formatEvent.ChecksumType switch
                {
                    ChecksumType.NONE => new NoneChecksum(),
                    ChecksumType.CRC32 => new Crc32Checksum(),
                    _ => throw new InvalidOperationException("The master checksum type is not supported.")
                };
            }
            if (binlogEvent is TableMapEvent tableMapEvent)
            {
                TableMapCache[tableMapEvent.TableId] = tableMapEvent;
            }

            return(binlogEvent);
        }
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new <see cref="PreviousGtidsEvent"/>.
 /// </summary>
 public PreviousGtidsEvent(EventHeader header, GtidSet gtidSet) : base(header)
 {
     GtidSet = gtidSet;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new <see cref="GtidListEvent"/>.
 /// </summary>
 public GtidListEvent(EventHeader header, List <string> gtidList) : base(header)
 {
     GtidList = gtidList;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new <see cref="GtidListEvent"/>.
 /// </summary>
 public GtidListEvent(EventHeader header, GtidList gtidList) : base(header)
 {
     GtidList = gtidList;
 }