Skip to content

Commit

Permalink
feat: support chart in agent
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Oct 18, 2024
1 parent 582d3e3 commit 0e92ee1
Show file tree
Hide file tree
Showing 30 changed files with 208 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.23.1
go 1.23.2

use (
.
Expand Down
2 changes: 1 addition & 1 deletion cmd/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siyul-park/uniflow/cmd

go 1.23.1
go 1.23.2

require (
github.com/go-faker/faker/v4 v4.5.0
Expand Down
2 changes: 2 additions & 0 deletions cmd/pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func runStartCommand(config StartConfig) func(cmd *cobra.Command, args []string)

h.AddLoadHook(a)
h.AddUnloadHook(a)
h.AddLinkHook(a)
h.AddUnlinkHook(a)

d := NewDebugger(
a,
Expand Down
18 changes: 6 additions & 12 deletions cmd/pkg/uniflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const (
)

func init() {
viper.SetDefault(flagCollectionCharts, "charts")
viper.SetDefault(flagCollectionNodes, "nodes")
viper.SetDefault(flagCollectionSecrets, "secrets")

viper.SetConfigFile(configFile)
viper.AutomaticEnv()
viper.ReadInConfig()
Expand All @@ -70,21 +74,11 @@ func main() {
ctx := context.Background()

databaseURL := viper.GetString(flagDatabaseURL)
databaseName := viper.GetString(flagCollectionCharts)
collectionCharts := viper.GetString(flagCollectionNodes)
databaseName := viper.GetString(flagDatabaseName)
collectionCharts := viper.GetString(flagCollectionCharts)
collectionNodes := viper.GetString(flagCollectionNodes)
collectionSecrets := viper.GetString(flagCollectionSecrets)

if collectionCharts == "" {
collectionCharts = "charts"
}
if collectionNodes == "" {
collectionNodes = "nodes"
}
if collectionSecrets == "" {
collectionSecrets = "secrets"
}

if strings.HasPrefix(databaseURL, "memongodb://") {
server := mongoserver.New()
defer server.Stop()
Expand Down
18 changes: 6 additions & 12 deletions cmd/pkg/uniflowctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const (
)

func init() {
viper.SetDefault(flagCollectionCharts, "charts")
viper.SetDefault(flagCollectionNodes, "nodes")
viper.SetDefault(flagCollectionSecrets, "secrets")

viper.SetConfigFile(configFile)
viper.AutomaticEnv()
viper.ReadInConfig()
Expand All @@ -40,21 +44,11 @@ func main() {
ctx := context.Background()

databaseURL := viper.GetString(flagDatabaseURL)
databaseName := viper.GetString(flagCollectionCharts)
collectionCharts := viper.GetString(flagCollectionNodes)
databaseName := viper.GetString(flagDatabaseName)
collectionCharts := viper.GetString(flagCollectionCharts)
collectionNodes := viper.GetString(flagCollectionNodes)
collectionSecrets := viper.GetString(flagCollectionSecrets)

if collectionCharts == "" {
collectionCharts = "charts"
}
if collectionNodes == "" {
collectionNodes = "nodes"
}
if collectionSecrets == "" {
collectionSecrets = "secrets"
}

if strings.HasPrefix(databaseURL, "memongodb://") {
server := mongoserver.New()
defer server.Stop()
Expand Down
2 changes: 1 addition & 1 deletion driver/mongo/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siyul-park/uniflow/driver/mongo

go 1.23.1
go 1.23.2

require (
github.com/go-faker/faker/v4 v4.5.0
Expand Down
4 changes: 2 additions & 2 deletions ext/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siyul-park/uniflow/ext

go 1.23.1
go 1.23.2

require (
github.com/andybalholm/brotli v1.1.1
Expand All @@ -26,7 +26,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
github.com/google/pprof v0.0.0-20241009165004-a3522334989c // indirect
github.com/google/pprof v0.0.0-20241017200806-017d972448fc // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions ext/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ github.com/google/cel-go v0.21.0 h1:cl6uW/gxN+Hy50tNYvI691+sXxioCnstFzLp2WO4GCI=
github.com/google/cel-go v0.21.0/go.mod h1:rHUlWCcBKgyEk+eV03RPdZUekPp6YcJwV0FxuUksYxc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20241009165004-a3522334989c h1:NDovD0SMpBYXlE1zJmS1q55vWB/fUQBcPAqAboZSccA=
github.com/google/pprof v0.0.0-20241009165004-a3522334989c/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/pprof v0.0.0-20241017200806-017d972448fc h1:NGyrhhFhwvRAZg02jnYVg3GBQy0qGBKmFQJwaPmpmxs=
github.com/google/pprof v0.0.0-20241017200806-017d972448fc/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
Expand Down
4 changes: 2 additions & 2 deletions ext/pkg/control/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (n *ForkNode) backward(proc *process.Process) {
continue
}

proc.Wait()
proc.Join()
proc.Exit(err)
}
}
Expand All @@ -118,7 +118,7 @@ func (n *ForkNode) catch(proc *process.Process) {
err = v.Unwrap()
}

proc.Wait()
proc.Join()
proc.Exit(err)
}
}
4 changes: 2 additions & 2 deletions ext/pkg/control/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestForkNode_SendAndReceive(t *testing.T) {

proc := process.New()
defer proc.Exit(nil)
defer proc.Wait()
defer proc.Join()

inWriter := in.Open(proc)

Expand Down Expand Up @@ -95,7 +95,7 @@ func BenchmarkForkNode_SendAndReceive(b *testing.B) {

proc := process.New()
defer proc.Exit(nil)
defer proc.Wait()
defer proc.Join()

inWriter := in.Open(proc)

Expand Down
2 changes: 1 addition & 1 deletion ext/pkg/control/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (n *SessionNode) forward(proc *process.Process) {
}

for _, child := range children {
child.Wait()
child.Join()
child.Exit(err)
}
}))
Expand Down
4 changes: 2 additions & 2 deletions ext/pkg/network/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (n *HTTPListenNode) ServeHTTP(w http.ResponseWriter, r *http.Request) {

go func() {
<-ctx.Done()
proc.Wait()
proc.Join()
proc.Exit(ctx.Err())
}()

Expand Down Expand Up @@ -238,7 +238,7 @@ func (n *HTTPListenNode) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

go func() {
proc.Wait()
proc.Join()
proc.Exit(err)
}()
}
Expand Down
4 changes: 2 additions & 2 deletions ext/pkg/network/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (n *WebSocketConnNode) produce(proc *process.Process) {
outPck := packet.New(outPayload)
packet.Send(outWriter, outPck)

proc.Wait()
proc.Join()
proc.Exit(nil)
return
}
Expand All @@ -279,7 +279,7 @@ func (n *WebSocketConnNode) produce(proc *process.Process) {
outPck := packet.New(outPayload)
packet.Send(outWriter, outPck)

child.Wait()
child.Join()
child.Exit(nil)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siyul-park/uniflow

go 1.23.1
go 1.23.2

require (
github.com/benbjohnson/immutable v0.4.3
Expand Down
Loading

0 comments on commit 0e92ee1

Please sign in to comment.