-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: move message definition and util functions to separate pkg
Also define vacuum and delete_msg structures, TBD
- Loading branch information
Showing
12 changed files
with
97 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package proc | ||
package message | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package proc | ||
package message | ||
|
||
import "encoding/binary" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package proc | ||
package message | ||
|
||
import ( | ||
"encoding/binary" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package message | ||
|
||
import ( | ||
"bytes" | ||
"encoding/binary" | ||
) | ||
|
||
type DeleteMessage struct { | ||
Name string | ||
} | ||
|
||
var _ ProtoMessage = &DeleteMessage{} | ||
|
||
func NewDeleteMessage(name string) *DeleteMessage { | ||
return &DeleteMessage{ | ||
Name: name, | ||
} | ||
} | ||
|
||
func (c *DeleteMessage) Encode() []byte { | ||
bt := []byte{ | ||
byte(MessageTypeDelete), | ||
0, | ||
0, | ||
0, | ||
} | ||
|
||
bt = append(bt, []byte(c.Name)...) | ||
bt = append(bt, 0) | ||
ln := len(bt) + 8 | ||
|
||
bs := make([]byte, 8) | ||
binary.BigEndian.PutUint64(bs, uint64(ln)) | ||
return append(bs, bt...) | ||
} | ||
|
||
func (c *DeleteMessage) Decode(body []byte) { | ||
c.Name = c.GetDeleteName(body[4:]) | ||
} | ||
|
||
func (c *DeleteMessage) GetDeleteName(b []byte) string { | ||
buff := bytes.NewBufferString("") | ||
|
||
for i := 0; i < len(b); i++ { | ||
if b[i] == 0 { | ||
break | ||
} | ||
buff.WriteByte(b[i]) | ||
} | ||
|
||
return buff.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package proc | ||
package message | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package proc | ||
package message | ||
|
||
import "encoding/binary" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package vacuum | ||
|
||
// Greenplum + yezzey specific logic for external storage vacuuming | ||
// Yezzey stores AO/AOCS relations data in one or several files in external | ||
// storage (chunks). Chunk considered to be obsolete when | ||
// table referencing this chunk was deleted and all backups (WAL-G) which | ||
// contains this table was deleted | ||
|
||
// TODO: implement |