Skip to content

Commit

Permalink
feat: remove tree modify
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangliang committed Jun 1, 2021
1 parent e13e5e2 commit 8196aef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
8 changes: 4 additions & 4 deletions examples/hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var task []byte
var helloB3 []byte

func main() {
engine := agent.NewEngine()
engine.RegisterHandlers(HelloHandlers())
engine.SetTreesFromConfig(helloB3)
engine.BuildEngineFromConfig(task)
behavior := agent.NewBehavior()
behavior.RegisterHandlers(HelloHandlers())
behavior.RegisterTreeConfig(helloB3)
engine := behavior.BuildEngineFromConfig(task)
a := agent.NewAgent(engine)
a.Start()
}
15 changes: 3 additions & 12 deletions pkg/agent/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

type Config struct {
Plans []*transfer.Plan
Trees []config.BTTreeCfg
Metadata map[string]string
}

Expand All @@ -27,18 +26,10 @@ func (c *Config) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, c)
}

func (c *Config) UnmarshalRawConfig(rawTree, rawOtherCfg []byte) error {
func (c *Config) UnmarshalRawConfig(rawCfg []byte) error {
var err error
if len(rawTree) != 0 {
var projectCfg config.RawProjectCfg
err = json.Unmarshal(rawTree, &projectCfg)
if err != nil {
return fmt.Errorf("unmarshal tree config err: %w", err)
}
c.Trees = projectCfg.Data.Trees
}
if len(rawOtherCfg) != 0 {
err = yaml.Unmarshal(rawOtherCfg, c)
if len(rawCfg) != 0 {
err = yaml.Unmarshal(rawCfg, c)
if err != nil {
return fmt.Errorf("unmarshal task config: %w", err)
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/agent/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ func (m *manager) startAgentEngine(content []byte) error {
if err != nil {
return err
}
if len(conf.Trees) != 0 {
m.engine.setTrees(conf.Trees)
}
if conf.Plans != nil {
m.engine.setPlans(conf.Plans)
}
Expand Down

0 comments on commit 8196aef

Please sign in to comment.