Skip to content

Commit

Permalink
refactor: add flow tag in yaml tag
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak160 <[email protected]>
  • Loading branch information
Sarthak160 committed Oct 16, 2023
1 parent bcab25f commit 3f3720f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
type Bind struct {
DestinationPortal string `json:"destination_portal,omitempty" yaml:"destination_portal,omitempty"`
PreparedStatement string `json:"prepared_statement,omitempty" yaml:"prepared_statement,omitempty"`
ParameterFormatCodes []int16 `json:"parameter_format_codes,omitempty" yaml:"parameter_format_codes,omitempty"`
Parameters [][]byte `json:"parameters,omitempty" yaml:"parameters,omitempty"`
ResultFormatCodes []int16 `json:"result_format_codes,omitempty" yaml:"result_format_codes,omitempty"`
ParameterFormatCodes []int16 `json:"parameter_format_codes,omitempty" yaml:"parameter_format_codes,omitempty,flow"`
Parameters [][]byte `json:"parameters,omitempty" yaml:"parameters,omitempty,flow"`
ResultFormatCodes []int16 `json:"result_format_codes,omitempty" yaml:"result_format_codes,omitempty,flow"`
}

// Frontend identifies this message as sendable by a PostgreSQL frontend.
Expand All @@ -39,6 +39,7 @@ func (dst *Bind) Decode(src []byte) error {
return &invalidMessageFormatErr{messageType: "Bind"}
}
dst.PreparedStatement = string(src[rp : rp+idx])
// fmt.Printf("PreparedStatement: %s\n", dst.PreparedStatement)
rp += idx + 1

if len(src[rp:]) < 2 {
Expand Down Expand Up @@ -104,7 +105,7 @@ func (dst *Bind) Decode(src []byte) error {
dst.ResultFormatCodes[i] = int16(binary.BigEndian.Uint16(src[rp:]))
rp += 2
}
dst.MarshalJSON()


return nil
}
Expand Down
8 changes: 5 additions & 3 deletions ssl_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
const sslRequestNumber = 80877103

type SSLRequest struct {
// if it doesn't work add here any struct
IsSSL bool `json:"is_ssl" yaml:"is_ssl"`
}

// Frontend identifies this message as sendable by a PostgreSQL frontend.
Expand All @@ -20,13 +22,13 @@ func (dst *SSLRequest) Decode(src []byte) error {
if len(src) < 4 {
return errors.New("ssl request too short")
}

requestCode := binary.BigEndian.Uint32(src)

dst.IsSSL = true
if requestCode != sslRequestNumber {
return errors.New("bad ssl request code")
}

return nil
}

Expand Down

0 comments on commit 3f3720f

Please sign in to comment.