Skip to content

Commit

Permalink
Merge pull request #93 from loopholelabs/staging
Browse files Browse the repository at this point in the history
Release v0.4.2
  • Loading branch information
ShivanshVij authored Apr 20, 2022
2 parents 54e9bfa + 0a968ca commit 83a7cc1
Show file tree
Hide file tree
Showing 30 changed files with 708 additions and 818 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
key: trunk-${{ runner.os }}

- name: Trunk Check
uses: trunk-io/trunk-action@v0.4.0-beta
uses: trunk-io/trunk-action@v1.0.0
12 changes: 6 additions & 6 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 0.1
cli:
version: 0.8.1-beta
version: 0.10.0-beta
lint:
enabled:
- gitleaks@7.6.1
- gofmt@1.17.6
- golangci-lint@1.42.1
- markdownlint@0.29.0
- prettier@2.4.1
- gitleaks@8.7.1
- gofmt@1.18.1
- golangci-lint@1.45.2
- markdownlint@0.31.1
- prettier@2.6.2
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.4.2] - 2022-04-20 (Beta)

## Changes

- Refactored the RPC Generator to use the `text/template`
package ([#90](https://github.com/loopholelabs/frisbee/pull/90))
- Updated `pkg/packet.Decoder` to require only a `[]byte` to create a new decoder, instead of
a `*packet.Packet` ([#92](https://github.com/loopholelabs/frisbee/pull/92))
- Updated Trunk Linter to v0.10.0-beta ([#92](https://github.com/loopholelabs/frisbee/pull/92))

## [v0.4.1] - 2022-03-24 (Beta)

## Changes
Expand Down Expand Up @@ -209,7 +219,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Initial Release of Frisbee

[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.1...HEAD
[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.2...HEAD
[v0.4.2]: https://github.com/loopholelabs/frisbee/compare/v0.4.1...v0.4.2
[v0.4.1]: https://github.com/loopholelabs/frisbee/compare/v0.4.0...v0.4.1
[v0.4.0]: https://github.com/loopholelabs/frisbee/compare/v0.3.2...v0.4.0
[v0.3.2]: https://github.com/loopholelabs/frisbee/compare/v0.3.1...v0.3.2
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Shivansh Vij <[email protected]> @shivanshvij
- Jonathan Sun <[email protected]> @jspsun
- Alex Sørlie Glomsaas <[email protected]> @supermanifolds
14 changes: 5 additions & 9 deletions pkg/packet/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,31 @@ import (
var decoderPool sync.Pool

type Decoder struct {
p *Packet
b []byte
}

func GetDecoder(p *Packet) (d *Decoder) {
func GetDecoder(b []byte) (d *Decoder) {
v := decoderPool.Get()
if v == nil {
d = &Decoder{
p: p,
b: p.Content.B,
b: b,
}
} else {
d = v.(*Decoder)
d.p = p
d.b = p.Content.B
d.b = b
}
return
}

func Return(d *Decoder) {
func ReturnDecoder(d *Decoder) {
if d != nil {
d.p = nil
d.b = nil
decoderPool.Put(d)
}
}

func (d *Decoder) Return() {
Return(d)
ReturnDecoder(d)
}

func (d *Decoder) Nil() (value bool) {
Expand Down
60 changes: 30 additions & 30 deletions pkg/packet/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestDecoderNil(t *testing.T) {
p := Get()
Encoder(p).Nil()

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value := d.Nil()
assert.True(t, value)

Expand All @@ -40,7 +40,7 @@ func TestDecoderNil(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Nil()
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value = d.Nil()
d.Return()
p.Content.Reset()
Expand All @@ -64,7 +64,7 @@ func TestDecoderMap(t *testing.T) {
e.String(k).Uint32(v)
}

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
size, err := d.Map(StringKind, Uint32Kind)
assert.NoError(t, err)
assert.Equal(t, uint32(len(m)), size)
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestDecoderMap(t *testing.T) {
for k, v = range m {
e.String(k).Uint32(v)
}
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
size, err = d.Map(StringKind, Uint32Kind)
for i := uint32(0); i < size; i++ {
_, _ = d.String()
Expand All @@ -118,7 +118,7 @@ func TestDecoderSlice(t *testing.T) {
e.String(v)
}

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
size, err := d.Slice(StringKind)
assert.NoError(t, err)
assert.Equal(t, uint32(len(m)), size)
Expand All @@ -143,7 +143,7 @@ func TestDecoderSlice(t *testing.T) {
for _, v := range m {
e.String(v)
}
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
size, err = d.Slice(StringKind)
for i := uint32(0); i < size; i++ {
_, _ = d.String()
Expand All @@ -164,7 +164,7 @@ func TestDecoderBytes(t *testing.T) {

Encoder(p).Bytes(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Bytes(nil)
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -177,7 +177,7 @@ func TestDecoderBytes(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Bytes(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Bytes(value)
d.Return()
p.Content.Reset()
Expand All @@ -195,7 +195,7 @@ func TestDecoderString(t *testing.T) {

Encoder(p).String(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.String()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -208,7 +208,7 @@ func TestDecoderString(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).String(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.String()
d.Return()
p.Content.Reset()
Expand All @@ -226,7 +226,7 @@ func TestDecoderError(t *testing.T) {

Encoder(p).Error(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Error()
assert.NoError(t, err)
assert.ErrorIs(t, value, v)
Expand All @@ -239,7 +239,7 @@ func TestDecoderError(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Error(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Error()
d.Return()
p.Content.Reset()
Expand All @@ -255,7 +255,7 @@ func TestDecoderBool(t *testing.T) {
p := Get()
Encoder(p).Bool(true)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Bool()
assert.NoError(t, err)
assert.True(t, value)
Expand All @@ -268,7 +268,7 @@ func TestDecoderBool(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Bool(true)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Bool()
d.Return()
p.Content.Reset()
Expand All @@ -286,7 +286,7 @@ func TestDecoderUint8(t *testing.T) {

Encoder(p).Uint8(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Uint8()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -299,7 +299,7 @@ func TestDecoderUint8(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Uint8(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Uint8()
d.Return()
p.Content.Reset()
Expand All @@ -317,7 +317,7 @@ func TestDecoderUint16(t *testing.T) {

Encoder(p).Uint16(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Uint16()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -330,7 +330,7 @@ func TestDecoderUint16(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Uint16(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Uint16()
d.Return()
p.Content.Reset()
Expand All @@ -348,7 +348,7 @@ func TestDecoderUint32(t *testing.T) {

Encoder(p).Uint32(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Uint32()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -361,7 +361,7 @@ func TestDecoderUint32(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Uint32(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Uint32()
d.Return()
p.Content.Reset()
Expand All @@ -379,7 +379,7 @@ func TestDecoderUint64(t *testing.T) {

Encoder(p).Uint64(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Uint64()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -392,7 +392,7 @@ func TestDecoderUint64(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Uint64(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Uint64()
d.Return()
p.Content.Reset()
Expand All @@ -410,7 +410,7 @@ func TestDecoderInt32(t *testing.T) {

Encoder(p).Int32(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Int32()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -423,7 +423,7 @@ func TestDecoderInt32(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Int32(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Int32()
d.Return()
p.Content.Reset()
Expand All @@ -441,7 +441,7 @@ func TestDecoderInt64(t *testing.T) {

Encoder(p).Int64(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Int64()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -454,7 +454,7 @@ func TestDecoderInt64(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Int64(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Int64()
d.Return()
p.Content.Reset()
Expand All @@ -472,7 +472,7 @@ func TestDecoderFloat32(t *testing.T) {

Encoder(p).Float32(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Float32()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -485,7 +485,7 @@ func TestDecoderFloat32(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Float32(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Float32()
d.Return()
p.Content.Reset()
Expand All @@ -503,7 +503,7 @@ func TestDecoderFloat64(t *testing.T) {

Encoder(p).Float64(v)

d := GetDecoder(p)
d := GetDecoder(p.Content.B)
value, err := d.Float64()
assert.NoError(t, err)
assert.Equal(t, v, value)
Expand All @@ -516,7 +516,7 @@ func TestDecoderFloat64(t *testing.T) {
p.Content.Reset()
n := testing.AllocsPerRun(100, func() {
Encoder(p).Float64(v)
d = GetDecoder(p)
d = GetDecoder(p.Content.B)
value, err = d.Float64()
d.Return()
p.Content.Reset()
Expand Down
Loading

0 comments on commit 83a7cc1

Please sign in to comment.