github.com/datastax/go-cassandra-native-protocol@v0.0.0-20220706104457-5e8aad05cf90/message/ready.go (about) 1 // Copyright 2020 DataStax 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package message 16 17 import ( 18 "errors" 19 "fmt" 20 "io" 21 22 "github.com/datastax/go-cassandra-native-protocol/primitive" 23 ) 24 25 // Ready is a response sent when the coordinator replies to a Startup request without requiring authentication. 26 // +k8s:deepcopy-gen=true 27 // +k8s:deepcopy-gen:interfaces=github.com/datastax/go-cassandra-native-protocol/message.Message 28 type Ready struct { 29 } 30 31 func (m *Ready) IsResponse() bool { 32 return true 33 } 34 35 func (m *Ready) GetOpCode() primitive.OpCode { 36 return primitive.OpCodeReady 37 } 38 39 func (m *Ready) String() string { 40 return "READY" 41 } 42 43 type readyCodec struct{} 44 45 func (c *readyCodec) Encode(msg Message, _ io.Writer, _ primitive.ProtocolVersion) error { 46 _, ok := msg.(*Ready) 47 if !ok { 48 return errors.New(fmt.Sprintf("expected *message.Ready, got %T", msg)) 49 } 50 return nil 51 } 52 53 func (c *readyCodec) EncodedLength(msg Message, _ primitive.ProtocolVersion) (int, error) { 54 _, ok := msg.(*Ready) 55 if !ok { 56 return -1, errors.New(fmt.Sprintf("expected *message.Ready, got %T", msg)) 57 } 58 return 0, nil 59 } 60 61 func (c *readyCodec) Decode(_ io.Reader, _ primitive.ProtocolVersion) (Message, error) { 62 return &Ready{}, nil 63 } 64 65 func (c *readyCodec) GetOpCode() primitive.OpCode { 66 return primitive.OpCodeReady 67 }