Skip to content

Commit

Permalink
Fix API refactor bugs
Browse files Browse the repository at this point in the history
  * Enable docker mode
  * Pass all unit tests
  * Consistant all error log format
  * Hack logrus to show correct call stack
  • Loading branch information
lileding committed Jan 16, 2019
1 parent 56d9146 commit a2d2071
Show file tree
Hide file tree
Showing 47 changed files with 528 additions and 1,177 deletions.
7 changes: 4 additions & 3 deletions Makefile
@@ -1,8 +1,9 @@
PREFIX?=/usr/local
VERSION?=$(shell git rev-list HEAD|head -1|cut -c 1-6)
VERSION?=git-$(shell git rev-list HEAD|head -1|cut -c 1-6)
PACKAGE_PREFIX?=
GOFLAG?=-ldflags "-X main.BuildTime=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X 'main.GoVersion=`go version`' -X 'main.Version=$(VERSION)' -X 'master.Version=$(VERSION)'"

all: openedge packages
all: openedge

packages: \
openedge-agent/package.tar.gz \
Expand Down Expand Up @@ -109,7 +110,7 @@ protobuf:
image:
make -C openedge-hub image
make -C openedge-function image
make -C openedge-function-runtime-python27 image
make -C openedge-function-python27 image
make -C openedge-remote-mqtt image
make -C openedge-agent image

Expand Down
48 changes: 0 additions & 48 deletions example/docker/var/db/openedge/module/localfunc/module.yml

This file was deleted.

13 changes: 0 additions & 13 deletions example/docker/var/db/openedge/module/module.yml

This file was deleted.

13 changes: 13 additions & 0 deletions example/docker/var/db/openedge/service/config.yml
@@ -0,0 +1,13 @@
version: V0
services:
localhub:
image: 'openedge-hub'
expose:
- 1883:1883
localfunc:
image: 'openedge-function'
resources:
cpu:
cpus: 1
memory:
limit: 500m
Expand Up @@ -45,12 +45,14 @@ def handler(event, context):
res['invoked'] = True
return res

event['USER_ID'] = os.environ['USER_ID']
event['functionName'] = context['functionName']
#event['USER_ID'] = os.environ['USER_ID']
event['functionName'] = context.function_name
'''
event['functionInvokeID'] = context['functionInvokeID']
event['invokeid'] = context['invokeid']
event['messageQOS'] = context['messageQOS']
event['messageTopic'] = context['messageTopic']
'''
event['py'] = '你好,世界!'

return event
Expand Down
27 changes: 27 additions & 0 deletions example/docker/var/db/openedge/service/localfunc/service.yml
@@ -0,0 +1,27 @@
name: localfunc
hub:
address: tcp://openedge-service-localhub:1883
username: test
password: hahaha
prefix: 'openedge-function-'
functions:
- name: 'sayhi'
runtime: 'python27'
handler: 'sayhi.handler'
codedir: 'func-nyeosbbch'
env:
USER_ID: acuiot
instance:
min: 0
max: 100
timeout: 30s
subscribe:
topic: t
qos: 1
publish:
topic: t/hi
qos: 1
logger:
path: var/log/openedge-service.log
console: true
level: "debug"
@@ -1,6 +1,6 @@
name: localhub
listen:
- tcp://:1883
- tcp://0.0.0.0:1883
principals:
- username: 'test'
password: 'be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912'
Expand All @@ -15,6 +15,6 @@ subscriptions:
target:
topic: 't/topic'
logger:
path: var/log/openedge/localhub/localhub.log
path: var/log/openedge-service.log
console: true
level: "debug"
2 changes: 1 addition & 1 deletion example/native/etc/openedge/openedge.yml
@@ -1,5 +1,5 @@
mode: native
logger:
path: var/log/openedge/openedge.log
console: false
console: true
level: debug
Expand Up @@ -23,5 +23,5 @@ functions:
qos: 1
logger:
path: var/log/openedge-service.log
console: false
console: true
level: "debug"
Expand Up @@ -16,5 +16,5 @@ subscriptions:
topic: 't/topic'
logger:
path: var/log/openedge-service.log
console: false
console: true
level: "debug"
16 changes: 15 additions & 1 deletion main.go
Expand Up @@ -11,9 +11,17 @@ import (

openedge "github.com/baidu/openedge/api/go"
"github.com/baidu/openedge/master"
_ "github.com/baidu/openedge/master/engine/docker"
_ "github.com/baidu/openedge/master/engine/native"
)

// compile variables
var (
Version string
BuildTime string
GoVersion string
)

const defaultConfig = "etc/openedge/openedge.yml"

func main() {
Expand All @@ -31,7 +39,13 @@ func main() {
var flagH = flag.Bool("h", false, "show this help")
flag.Parse()
if *flagH {
fmt.Fprintf(flag.CommandLine.Output(), "Version of %s: %s\n", os.Args[0], master.Version)
fmt.Fprintf(
flag.CommandLine.Output(),
"OpenEdge version %s\nbuild time %s\n%s\n\n",
Version,
BuildTime,
GoVersion,
)
flag.Usage()
return
}
Expand Down
74 changes: 0 additions & 74 deletions master/config_test.go

This file was deleted.

0 comments on commit a2d2071

Please sign in to comment.