Skip to content

Commit

Permalink
Merge pull request #100 from project-flogo/fix-issue-99
Browse files Browse the repository at this point in the history
Fix issue 99
  • Loading branch information
rameshpolishetti authored Apr 27, 2020
2 parents 8b7a53a + 50eb9ba commit d6de892
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 76 deletions.
3 changes: 1 addition & 2 deletions examples/flogo/creditcard/flogo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"appModel": "1.0.0",
"imports": [
"github.com/project-flogo/contrib/trigger/rest",
"github.com/project-flogo/rules/ruleaction",
"github.com/project-flogo/legacybridge"
"github.com/project-flogo/rules/ruleaction"
],
"triggers": [
{
Expand Down
6 changes: 6 additions & 0 deletions examples/flogo/creditcard/imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

import (
_ "github.com/project-flogo/rules/ruleaction"
_ "github.com/project-flogo/contrib/trigger/rest"
)
34 changes: 20 additions & 14 deletions examples/flogo/creditcard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,43 @@ import (

_ "github.com/project-flogo/core/data/expression/script"
"github.com/project-flogo/core/engine"
"github.com/project-flogo/core/support/log"

_ "github.com/project-flogo/contrib/trigger/rest"
_ "github.com/project-flogo/rules/ruleaction"
)

var (
cpuProfile = flag.String("cpuprofile", "", "Writes CPU profile to the specified file")
memProfile = flag.String("memprofile", "", "Writes memory profile to the specified file")
cfgJson string
cfgEngine string
cfgCompressed bool
)

func main() {

cpuProfiling := false

flag.Parse()
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create CPU profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create CPU profiling file: %v\n", err)
os.Exit(1)
}
if err = pprof.StartCPUProfile(f); err != nil {
fmt.Fprintf(os.Stderr, "Failed to start CPU profiling: %v\n", err)
os.Exit(1)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
cpuProfiling = true
}

cfg, err := engine.LoadAppConfig(cfgJson, cfgCompressed)
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

e, err := engine.New(cfg)
e, err := engine.New(cfg, engine.ConfigOption(cfgEngine, cfgCompressed))
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

Expand All @@ -52,17 +54,21 @@ func main() {
if *memProfile != "" {
f, err := os.Create(*memProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create memory profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create memory profiling file: %v\n", err)
os.Exit(1)
}

runtime.GC() // get up-to-date statistics
if err := pprof.WriteHeapProfile(f); err != nil {
fmt.Println(fmt.Sprintf("Failed to write memory profiling data to file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to write memory profiling data: %v", err)
os.Exit(1)
}
f.Close()
_ = f.Close()
}

if cpuProfiling {
pprof.StopCPUProfile()
}

os.Exit(code)
}
}
4 changes: 4 additions & 0 deletions examples/flogo/simple-kafka/flogo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"version": "0.0.1",
"description": "Sample Flogo App",
"appModel": "1.0.0",
"imports": [
"github.com/project-flogo/contrib/trigger/kafka",
"github.com/project-flogo/rules/ruleaction"
],
"triggers": [
{
"id": "receive_kafka_message",
Expand Down
6 changes: 6 additions & 0 deletions examples/flogo/simple-kafka/imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

import (
_ "github.com/project-flogo/contrib/trigger/kafka"
_ "github.com/project-flogo/rules/ruleaction"
)
38 changes: 22 additions & 16 deletions examples/flogo/simple-kafka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,43 @@ import (

_ "github.com/project-flogo/core/data/expression/script"
"github.com/project-flogo/core/engine"
"github.com/project-flogo/core/support/log"

_ "github.com/project-flogo/contrib/trigger/kafka"
_ "github.com/project-flogo/rules/ruleaction"
)

var (
cpuProfile = flag.String("cpuprofile", "", "Writes CPU profile to the specified file")
memProfile = flag.String("memprofile", "", "Writes memory profile to the specified file")
cfgJSON string
cfgJson string
cfgEngine string
cfgCompressed bool
)

func main() {

cpuProfiling := false

flag.Parse()
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create CPU profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create CPU profiling file: %v\n", err)
os.Exit(1)
}
if err = pprof.StartCPUProfile(f); err != nil {
fmt.Fprintf(os.Stderr, "Failed to start CPU profiling: %v\n", err)
os.Exit(1)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
cpuProfiling = true
}

cfg, err := engine.LoadAppConfig(cfgJSON, cfgCompressed)
cfg, err := engine.LoadAppConfig(cfgJson, cfgCompressed)
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

e, err := engine.New(cfg)
e, err := engine.New(cfg, engine.ConfigOption(cfgEngine, cfgCompressed))
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

Expand All @@ -52,17 +54,21 @@ func main() {
if *memProfile != "" {
f, err := os.Create(*memProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create memory profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create memory profiling file: %v\n", err)
os.Exit(1)
}

runtime.GC() // get up-to-date statistics
if err := pprof.WriteHeapProfile(f); err != nil {
fmt.Println(fmt.Sprintf("Failed to write memory profiling data to file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to write memory profiling data: %v", err)
os.Exit(1)
}
f.Close()
_ = f.Close()
}

if cpuProfiling {
pprof.StopCPUProfile()
}

os.Exit(code)
}
}
4 changes: 4 additions & 0 deletions examples/flogo/simple/flogo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"version": "0.0.1",
"description": "Sample Flogo App",
"appModel": "1.0.0",
"imports": [
"github.com/project-flogo/contrib/trigger/rest",
"github.com/project-flogo/rules/ruleaction"
],
"triggers": [
{
"id": "receive_http_message",
Expand Down
6 changes: 6 additions & 0 deletions examples/flogo/simple/imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

import (
_ "github.com/project-flogo/contrib/trigger/rest"
_ "github.com/project-flogo/rules/ruleaction"
)
41 changes: 23 additions & 18 deletions examples/flogo/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,43 @@ import (

_ "github.com/project-flogo/core/data/expression/script"
"github.com/project-flogo/core/engine"
"github.com/project-flogo/core/support/log"

_ "github.com/project-flogo/contrib/trigger/rest"
_ "github.com/project-flogo/rules/ruleaction"

)

var (
cpuProfile = flag.String("cpuprofile", "", "Writes CPU profile to the specified file")
memProfile = flag.String("memprofile", "", "Writes memory profile to the specified file")
cfgJson string
cpuProfile = flag.String("cpuprofile", "", "Writes CPU profile to the specified file")
memProfile = flag.String("memprofile", "", "Writes memory profile to the specified file")
cfgJson string
cfgEngine string
cfgCompressed bool
)

func main() {

cpuProfiling := false

flag.Parse()
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create CPU profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create CPU profiling file: %v\n", err)
os.Exit(1)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
if err = pprof.StartCPUProfile(f); err != nil {
fmt.Fprintf(os.Stderr, "Failed to start CPU profiling: %v\n", err)
os.Exit(1)
}
cpuProfiling = true
}

cfg, err := engine.LoadAppConfig(cfgJson, cfgCompressed)
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

e, err := engine.New(cfg)
e, err := engine.New(cfg, engine.ConfigOption(cfgEngine, cfgCompressed))
if err != nil {
log.RootLogger().Errorf("Failed to create engine: %s", err.Error())
fmt.Fprintf(os.Stderr, "Failed to create engine: %v\n", err)
os.Exit(1)
}

Expand All @@ -53,17 +54,21 @@ func main() {
if *memProfile != "" {
f, err := os.Create(*memProfile)
if err != nil {
fmt.Println(fmt.Sprintf("Failed to create memory profiling file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to create memory profiling file: %v\n", err)
os.Exit(1)
}

runtime.GC() // get up-to-date statistics
if err := pprof.WriteHeapProfile(f); err != nil {
fmt.Println(fmt.Sprintf("Failed to write memory profiling data to file due to error - %s", err.Error()))
fmt.Fprintf(os.Stderr, "Failed to write memory profiling data: %v", err)
os.Exit(1)
}
f.Close()
_ = f.Close()
}

if cpuProfiling {
pprof.StopCPUProfile()
}

os.Exit(code)
}
}
4 changes: 4 additions & 0 deletions examples/flogo/trackntrace/flogo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"type": "flogo:app",
"version": "0.0.1",
"appModel": "1.0.0",
"imports": [
"github.com/project-flogo/contrib/trigger/rest",
"github.com/project-flogo/rules/ruleaction"
],
"triggers": [
{
"id": "receive_http_message",
Expand Down
6 changes: 6 additions & 0 deletions examples/flogo/trackntrace/imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

import (
_ "github.com/project-flogo/contrib/trigger/rest"
_ "github.com/project-flogo/rules/ruleaction"
)
Loading

0 comments on commit d6de892

Please sign in to comment.