fieldalignment of all structs to save memory

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-04-27 08:32:47 +03:00
parent ee11f39a2f
commit 86626c5922
78 changed files with 343 additions and 410 deletions

View File

@@ -5,9 +5,11 @@ import (
"context"
)
type mdIncomingKey struct{}
type mdOutgoingKey struct{}
type mdKey struct{}
type (
mdIncomingKey struct{}
mdOutgoingKey struct{}
mdKey struct{}
)
// FromIncomingContext returns metadata from incoming ctx
// returned metadata shoud not be modified or race condition happens

View File

@@ -6,10 +6,8 @@ import (
"sort"
)
var (
// HeaderPrefix for all headers passed
HeaderPrefix = "Micro-"
)
// HeaderPrefix for all headers passed
var HeaderPrefix = "Micro-"
// Metadata is our way of representing request headers internally.
// They're used at the RPC level and translate back and forth
@@ -20,10 +18,8 @@ type rawMetadata struct {
md Metadata
}
var (
// defaultMetadataSize used when need to init new Metadata
defaultMetadataSize = 2
)
// defaultMetadataSize used when need to init new Metadata
var defaultMetadataSize = 2
// Iterator used to iterate over metadata with order
type Iterator struct {

View File

@@ -76,7 +76,7 @@ func TestIterator(t *testing.T) {
var k, v string
for iter.Next(&k, &v) {
//fmt.Printf("k: %s, v: %s\n", k, v)
// fmt.Printf("k: %s, v: %s\n", k, v)
}
}
@@ -102,7 +102,6 @@ func TestMedataCanonicalKey(t *testing.T) {
} else if v != "12345" {
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
}
}
func TestMetadataSet(t *testing.T) {
@@ -130,7 +129,6 @@ func TestMetadataDelete(t *testing.T) {
if ok {
t.Fatal("key Baz not deleted")
}
}
func TestNilContext(t *testing.T) {