protected override void WriteFrame(IFrameWriter fw) { Stream stream = fw.WriteOnlyStream; stream.WriteLongString(CQL); fw.SetMessageType(MessageOpcodes.Prepare); }
protected override void WriteFrame(IFrameWriter fw) { Stream stream = fw.WriteOnlyStream; stream.WriteLongString(CQL); stream.WriteUShort((ushort)ConsistencyLevel); fw.SetMessageType(MessageOpcodes.Query); }
protected override void WriteFrame(IFrameWriter fw) { var cql = "USE " + _keyspace; Stream stream = fw.WriteOnlyStream; stream.WriteLongString(cql); stream.WriteUShort((ushort)ConsistencyLevel); stream.WriteByte(0); fw.SetMessageType(MessageOpcodes.Query); }
protected override void WriteFrame(IFrameWriter fw) { Dictionary <string, string> options = new Dictionary <string, string> { { "CQL_VERSION", _cqlVersion } }; fw.WriteOnlyStream.WriteStringMap(options); fw.SetMessageType(MessageOpcodes.Startup); }
protected override void WriteFrame(IFrameWriter fw) { Stream stream = fw.WriteOnlyStream; Dictionary <string, string> authParams = new Dictionary <string, string> { { "username", _user }, { "password", _password } }; stream.WriteStringMap(authParams); fw.SetMessageType(MessageOpcodes.Credentials); }
protected override void WriteFrame(IFrameWriter fw) { Stream stream = fw.WriteOnlyStream; stream.WriteShortByteArray(_id); stream.WriteUShort((ushort)_columnSpecs.Length); foreach (var columnData in _mapperIn.MapToColumns(_dataSource, _columnSpecs)) { stream.WriteByteArray(columnData.RawData); } stream.WriteUShort((ushort)ConsistencyLevel); fw.SetMessageType(MessageOpcodes.Batch); }
protected override void WriteFrame(IFrameWriter fw) { StringBuilder sb = new StringBuilder("CREATE KEYSPACE "); sb.Append(_name); sb.Append(" WITH replication = {"); sb.Append(string.Join(",", _replicationOptions.Select(x => string.Format("'{0}': '{1}'", x.Key, x.Value)))); sb.Append("} AND durable_writes = "); sb.Append(_durableWrites); Stream stream = fw.WriteOnlyStream; stream.WriteLongString(sb.ToString()); stream.WriteUShort((ushort)ConsistencyLevel); fw.SetMessageType(MessageOpcodes.Query); }
private void WriteExecuteRequest(IFrameWriter frameWriter, ConsistencyLevel cl, IDataMapperFactory factory) { frameWriter.WriteShortByteArray(_id); frameWriter.WriteShort((short) _columnSpecs.Length); IDataSource dataSource = factory.DataSource; foreach (IColumnSpec columnSpec in _columnSpecs) { object data = dataSource.Get(columnSpec); byte[] rawData = columnSpec.Serialize(data); frameWriter.WriteByteArray(rawData); } frameWriter.WriteShort((short) cl); frameWriter.Send(MessageOpcodes.Execute); }
protected sealed override async ValueTask WriteFrameAsync( IFrameWriter frameWriter, CancellationToken cancellationToken = default) { await frameWriter.WriteUShortAsync( Version ^ 0x8000, cancellationToken) .ConfigureAwait(false); await frameWriter.WriteUShortAsync(_type, cancellationToken) .ConfigureAwait(false); await frameWriter.WriteByteAsync(Flags, cancellationToken) .ConfigureAwait(false); await WriteControlFrameAsync(frameWriter, cancellationToken) .ConfigureAwait(false); }
protected override async ValueTask WriteFrameAsync( IFrameWriter frameWriter, CancellationToken cancellationToken = default) { var data = StreamId .SetBit(31, false); await frameWriter.WriteUInt32Async(data, cancellationToken) .ConfigureAwait(false); await frameWriter.WriteByteAsync((byte)Flags, cancellationToken) .ConfigureAwait(false); await frameWriter.WriteUInt24Async( UInt24.From((uint)Payload.Length), cancellationToken) .ConfigureAwait(false); await frameWriter.WriteBytesAsync(Payload, cancellationToken) .ConfigureAwait(false); }
internal static async ValueTask WriteNameValuePairs( this IFrameWriter frameWriter, IReadOnlyDictionary <string, string[]> nameValuePairs, CancellationToken cancellationToken) { await frameWriter.WriteInt32Async( nameValuePairs.Count, cancellationToken) .ConfigureAwait(false); foreach (var(name, values) in nameValuePairs) { await frameWriter .WriteStringAsync(name, Encoding.ASCII, cancellationToken) .ConfigureAwait(false); await frameWriter .WriteStringAsync( string.Join(SpdyConstants.Nul, values), Encoding.ASCII, cancellationToken) .ConfigureAwait(false); } }
protected abstract ValueTask WriteControlFrameAsync( IFrameWriter frameWriter, CancellationToken cancellationToken = default);
protected abstract void WriteFrame(IFrameWriter frameWriter);
private static void WriteOptions(IFrameWriter frameWriter) { frameWriter.SetMessageType(MessageOpcodes.Options); }
/// <summary> /// Initializes a new instance of the <see cref="BinFrameWriterTest"/> class. /// </summary> public BinFrameWriterTest() { binFrameWriter = new BinFrameWriter(); }
/// <summary> /// You must use <see cref="Reset"/> before using the Encode methods. /// </summary> /// <param name="frameWriter"></param> public FrameEncoder(IFrameWriter <TFrame> frameWriter) => _frameWriter = frameWriter;
private static void WriteAuthenticate(IFrameWriter frameWriter, string user, string password) { Stream stream = frameWriter.WriteOnlyStream; Dictionary<string, string> authParams = new Dictionary<string, string> { {"username", user}, {"password", password} }; stream.WriteStringMap(authParams); frameWriter.SetMessageType(MessageOpcodes.Credentials); }
private static void WritePrepareRequest(IFrameWriter frameWriter, string cql) { Stream stream = frameWriter.WriteOnlyStream; stream.WriteLongString(cql); frameWriter.SetMessageType(MessageOpcodes.Prepare); }
public abstract void Write(IFrameWriter frameWriter);
private static void WriteQueryRequest(IFrameWriter frameWriter, string cql, ConsistencyLevel cl, MessageOpcodes opcode) { Stream stream = frameWriter.WriteOnlyStream; stream.WriteLongString(cql); stream.WriteShort((short) cl); frameWriter.SetMessageType(opcode); }
protected override void WriteFrame(IFrameWriter fw) { fw.SetMessageType(MessageOpcodes.Options); }
private static void WriteExecuteRequest(IFrameWriter frameWriter, byte[] id, IColumnSpec[] columnSpecs, ConsistencyLevel cl, IDataMapperFactory factory) { Stream stream = frameWriter.WriteOnlyStream; stream.WriteShortByteArray(id); stream.WriteShort((short) columnSpecs.Length); IDataSource dataSource = factory.DataSource; foreach (IColumnSpec columnSpec in columnSpecs) { object data = dataSource.Get(columnSpec); byte[] rawData = columnSpec.Serialize(data); stream.WriteByteArray(rawData); } stream.WriteShort((short) cl); frameWriter.SetMessageType(MessageOpcodes.Execute); }
private static void WriteReady(IFrameWriter frameWriter, string cqlVersion) { Dictionary<string, string> options = new Dictionary<string, string> { {"CQL_VERSION", cqlVersion} }; frameWriter.WriteOnlyStream.WriteStringMap(options); frameWriter.SetMessageType(MessageOpcodes.Startup); }