Skip to content

Commit

Permalink
Merge pull request #11 from iomz/test-github-action
Browse files Browse the repository at this point in the history
test: pass the test with go 1.23
  • Loading branch information
iomz authored Oct 26, 2024
2 parents 451c034 + 1f6ac16 commit 99b620f
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 131 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Codecov

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Test

on:
pull_request:
branches:
- main

jobs:
test:
strategy:
matrix:
go-version: [1.23.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: go test ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
test/*
*.csv
*.json
coverage.txt

# exp dir
exp/
Expand Down
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
gosstrak-fc
==
# gosstrak-fc

[![Build Status](https://travis-ci.org/iomz/gosstrak.svg?branch=master)](https://travis-ci.org/iomz/gosstrak)
<!---[![Coverage Status](https://coveralls.io/repos/iomz/gosstrak/badge.svg?branch=master)](https://coveralls.io/github/iomz/gosstrak?branch=master)--->
[![codecov](https://codecov.io/gh/iomz/gosstrak/branch/master/graph/badge.svg)](https://codecov.io/gh/iomz/gosstrak)
[![Test](https://github.com/iomz/gosstrak/actions/workflows/test.yml/badge.svg)](https://github.com/iomz/gosstrak/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/iomz/gosstrak)](https://goreportcard.com/report/github.com/iomz/gosstrak)
[![codecov](https://codecov.io/gh/iomz/gosstrak/branch/main/graph/badge.svg?token=fN1tyc6ssX)](https://codecov.io/gh/iomz/gosstrak)
[![GoDoc](https://godoc.org/github.com/iomz/gosstrak?status.svg)](http://godoc.org/github.com/iomz/gosstrak)
[![License](https://img.shields.io/github/license/iomz/gosstrak.svg)](https://github.com/iomz/gosstrak/blob/main/LICENSE)

## Stat Monitoring

Stat Monitoring
--
gosstrak collects statistical metrics and write them to InfluxDB for visualization in Grafana.
For quick start, use the docker-compose file and initialize the InfluxDB.

Expand All @@ -22,8 +21,7 @@ For quick start, use the docker-compose file and initialize the InfluxDB.

Then, run `gosstrak-fc` with `--enableStat` flag.

TDT Benchmark
--
## TDT Benchmark

```bash
BenchmarkTranslate100Tags-32 10000 283151 ns/op 34096 B/op 1321 allocs/op
Expand All @@ -38,11 +36,10 @@ BenchmarkTranslate900Tags-32 1000 2599413 ns/op
BenchmarkTranslate1000Tags-32 1000 2938569 ns/op 342385 B/op 13247 allocs/op
```

Author
--
## Author

Iori Mizutani (iomz)

License
--
## License

See `LICENSE` file.
56 changes: 28 additions & 28 deletions cmd/ale-ec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
package main

import (
"io"
"log"
"net"
"os"

"github.com/docker/libchan/spdy"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/alecthomas/kingpin/v2"
"github.com/moby/spdystream"
)

// Notification is the struct to send/receive captured ID
Expand Down Expand Up @@ -44,35 +43,36 @@ func main() {
log.Print(err)
break
}
p, err := spdy.NewSpdyStreamProvider(c, true)

spdyConn, err := spdystream.NewConnection(c, true)
if err != nil {
log.Print(err)
break
continue
}
t := spdy.NewTransport(p)
go spdyConn.Serve(spdystream.MirrorStreamHandler)

go func() {
for {
receiver, err := t.WaitReceiveChannel()
if err != nil {
log.Print(err)
break
}
// go func() {
// for {
// receiver, err := t.WaitReceiveChannel()
// if err != nil {
// log.Print(err)
// break
// }

go func() {
for {
noti := &Notification{}
err := receiver.Receive(noti)
if err != nil {
if err != io.EOF {
log.Print(err)
}
break
}
log.Println(noti.ID)
}
}()
}
}()
// go func() {
// for {
// noti := &Notification{}
// err := receiver.Receive(noti)
// if err != nil {
// if err != io.EOF {
// log.Print(err)
// }
// break
// }
// log.Println(noti.ID)
// }
// }()
// }
// }()
}
}
34 changes: 17 additions & 17 deletions cmd/gosstrak-fc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"runtime"
"time"

"github.com/docker/libchan/spdy"
"github.com/alecthomas/kingpin/v2"
"github.com/iomz/go-llrp"
"github.com/iomz/gosstrak/filtering"
"github.com/iomz/gosstrak/monitoring"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/moby/spdystream"
)

// Notification is the struct to send/receive captured ID
Expand Down Expand Up @@ -189,27 +189,27 @@ func run() {
log.Fatal(err)
break
}
p, err := spdy.NewSpdyStreamProvider(c, true)
spdyConn, err := spdystream.NewConnection(c, true)
if err != nil {
log.Print(err)
continue
}
t := spdy.NewTransport(p)
go spdyConn.Serve(spdystream.MirrorStreamHandler)

receiver, err := t.WaitReceiveChannel()
if err != nil {
log.Print(err)
continue
}
// receiver, err := t.WaitReceiveChannel()
// if err != nil {
// log.Print(err)
// continue
// }

mm := &filtering.ManagementMessage{}
err = receiver.Receive(mm)
if err != nil {
log.Print(err)
continue
}
log.Print(mm)
mc <- *mm
// mm := &filtering.ManagementMessage{}
// err = receiver.Receive(mm)
// if err != nil {
// log.Print(err)
// continue
// }
// log.Print(mm)
// mc <- *mm
}
log.Fatalln("managementListener closed in gosstrak-fc")
}()
Expand Down
3 changes: 2 additions & 1 deletion filtering/engine_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package filtering

import (
"context"
"log"
"reflect"
"sync"
Expand Down Expand Up @@ -197,6 +198,6 @@ func (ef *EngineFactory) Run() {
log.Println("[EngineFactory] initializing engines")
for _, eg := range ef.productionSystem {
// pass the cloned subscriptions
eg.FSM.Event("init", ef.currentSubscriptions)
eg.FSM.Event(context.Background(), "init", ef.currentSubscriptions)
}
}
20 changes: 11 additions & 9 deletions filtering/engine_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
package filtering

import (
"context"
"log"
"math"
"time"

//"reflect"

"github.com/iomz/go-llrp"
Expand Down Expand Up @@ -54,11 +56,11 @@ func NewEngineGenerator(name string, ec EngineConstructor, statInterval int, mc
{Name: "rebuild", Src: []string{"pending"}, Dst: "rebuilding"},
},
fsm.Callbacks{
"enter_state": func(e *fsm.Event) { eg.enterState(e) },
"enter_generating": func(e *fsm.Event) { eg.enterGenerating(e) },
"enter_ready": func(e *fsm.Event) { eg.enterReady(e) },
"enter_pending": func(e *fsm.Event) { eg.enterPending(e) },
"enter_rebuilding": func(e *fsm.Event) { eg.enterRebuilding(e) },
"enter_state": func(_ context.Context, e *fsm.Event) { eg.enterState(e) },
"enter_generating": func(_ context.Context, e *fsm.Event) { eg.enterGenerating(e) },
"enter_ready": func(_ context.Context, e *fsm.Event) { eg.enterReady(e) },
"enter_pending": func(_ context.Context, e *fsm.Event) { eg.enterPending(e) },
"enter_rebuilding": func(_ context.Context, e *fsm.Event) { eg.enterRebuilding(e) },
},
)

Expand Down Expand Up @@ -121,7 +123,7 @@ func (eg *EngineGenerator) enterGenerating(e *fsm.Event) {
//log.Printf("[EngineGenerator] start generating %s engine", eg.Name)
sub := e.Args[0].(Subscriptions)
eg.Engine = AvailableEngines[eg.Name](sub)
eg.FSM.Event("deploy")
eg.FSM.Event(context.Background(), "deploy")
}()
}

Expand All @@ -147,18 +149,18 @@ func (eg *EngineGenerator) enterRebuilding(e *fsm.Event) {
})
*/
}
eg.FSM.Event("deploy")
eg.FSM.Event(context.Background(), "deploy")
}

func (eg *EngineGenerator) enterReady(e *fsm.Event) {
log.Printf("[EngineGenerator] finished gererating %s engine", eg.Name)
eg.managementChannel <- ManagementMessage{
Type: OnEngineGenerated,
Type: OnEngineGenerated,
EngineGeneratorInstance: eg,
}
}

func (eg *EngineGenerator) enterPending(e *fsm.Event) {
// Wait until the engine finishes the current execution
eg.FSM.Event("rebuild", e.Args[0].(*ManagementMessage))
eg.FSM.Event(context.Background(), "rebuild", e.Args[0].(*ManagementMessage))
}
Loading

0 comments on commit 99b620f

Please sign in to comment.