Skip to content

Commit 71bf643

Browse files
authored
Merge pull request #192 from hooligan520/master
update changelog
2 parents 796b573 + 8a1a13e commit 71bf643

11 files changed

+60
-37
lines changed

Changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.1.2 (2020/04/23)
4+
### ChangLogs
5+
- merge from tars internal version
36

47
## 1.1.1 (2020/04/06)
58
### ChangLogs

tars/tools/Demo/Servant.tars

100644100755
+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
module _APP_{
2-
interface _SERVANT_{
3-
4-
int Add(int a,int b,out int c); // Some example function
5-
int Sub(int a,int b,out int c); // Some example function
6-
};
1+
module _APP_
2+
{
3+
interface _SERVANT_
4+
{
5+
int Add(int a,int b,out int c); // Some example function
6+
int Sub(int a,int b,out int c); // Some example function
7+
};
78
};

tars/tools/Demo/ServantImp.go tars/tools/Demo/Servant_imp.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import (
44
"context"
55
)
66

7+
// _SERVANT_Imp servant implementation
78
type _SERVANT_Imp struct {
89
}
910

10-
func (imp *_SERVANT_Imp) Init() (int, error) {
11+
// Init servant init
12+
func (imp *_SERVANT_Imp) Init() (error) {
1113
//initialize servant here:
1214
//...
13-
return 0,nil
15+
return nil
1416
}
1517

16-
//////////////////////////////////////////////////////
18+
// Destroy servant destory
1719
func (imp *_SERVANT_Imp) Destroy() {
1820
//destroy servant here:
1921
//...

tars/tools/Demo/Server.go

-15
This file was deleted.
File renamed without changes.

tars/tools/Demo/main.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/TarsCloud/TarsGo/tars"
8+
9+
"_APP_"
10+
)
11+
12+
func main() {
13+
// Get server config
14+
cfg := tars.GetServerConfig()
15+
16+
// New servant imp
17+
imp := new(_SERVANT_Imp)
18+
err := imp.Init()
19+
if err != nil {
20+
fmt.Printf("_SERVANT_Imp init fail, err:(%s)\n", err)
21+
os.Exit(-1)
22+
}
23+
// New servant
24+
app := new(_APP_._SERVANT_)
25+
// Register Servant
26+
app.AddServantWithContext(imp, cfg.App+"."+cfg.Server+"._SERVANT_Obj")
27+
28+
// Run application
29+
tars.Run()
30+
}

tars/tools/Demo/start.sh

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
make
3-
./_SERVER_ --config=_SERVER_.conf
3+
./_SERVER_ --config=config.conf

tars/tools/Demo4GoMod/Servant_imp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ type _SERVANT_Imp struct {
99
}
1010

1111
// Init servant init
12-
func (imp *_SERVANT_Imp) Init() (int, error) {
12+
func (imp *_SERVANT_Imp) Init() (error) {
1313
//initialize servant here:
1414
//...
15-
return 0,nil
15+
return nil
1616
}
1717

1818
// Destroy servant destory

tars/tools/Demo4GoMod/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func main() {
1515

1616
// New servant imp
1717
imp := new(_SERVANT_Imp)
18-
ret, err := imp.Init()
18+
err := imp.Init()
1919
if err != nil {
20-
fmt.Printf("_SERVANT_Imp init fail, ret:%d, err:(%s)\n", ret, err)
20+
fmt.Printf("_SERVANT_Imp init fail, err:(%s)\n", err)
2121
os.Exit(-1)
2222
}
2323
// New servant

tars/tools/create_tars_server.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,24 @@ else
6969
for FILE in $SRC_FILE client/client.go vendor/vendor.json debugtool/dumpstack.go
7070
do
7171
echo ">>>Now doing:"$FILE" >>>>"
72-
sed -i "s/_APP_/$APP/g" $FILE
73-
sed -i "s/_SERVER_/$SERVER/g" $FILE
74-
sed -i "s/_SERVANT_/$SERVANT/g" $FILE
72+
sed -i "s/_APP_/$APP/g" $FILE
73+
sed -i "s/_SERVER_/$SERVER/g" $FILE
74+
sed -i "s/_SERVANT_/$SERVANT/g" $FILE
7575
done
7676

77+
SERVANT_LC=`echo $SERVANT|tr 'A-Z' 'a-z'`
7778
for RENAMEFILE in `ls `
7879
do
7980
rename "Server" "$SERVER" $RENAMEFILE
80-
rename "Servant" "$SERVANT" $RENAMEFILE
81+
rename "Servant.tars" "${SERVANT}.tars" $RENAMEFILE
82+
rename "Servant_imp.go" "${SERVANT_LC}_imp.go" $RENAMEFILE
8183
done
8284
fi
8385

8486
# try build tars2go
85-
cd "$GOPATH/src/github.com/TarsCloud/TarsGo/tars/tools/tars2go"
87+
cd "$SRC_DIR/tars2go"
8688
go install
87-
cd "$GOPATH/src/$APP/$SERVER"
89+
cd $TARGET
8890
echo ">>> Great!Done! You can jump in "`pwd`
8991

9092
# show tips: how to convert tars to golang

tars/tools/create_tars_server_gomod.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cp -r $DEBUGDIR $TARGET
4949

5050
if [ `uname` == "Darwin" ] # support macOS
5151
then
52-
for FILE in $SRC_FILE client/client.go
52+
for FILE in $SRC_FILE client/client.go debugtool/dumpstack.go
5353
do
5454
echo ">>>Now doing:"$FILE" >>>>"
5555
sed -i "" "s/_APP_/$APP/g" $FILE
@@ -90,7 +90,7 @@ fi
9090
# try build tars2go
9191
cd "$SRC_DIR/tars2go"
9292
go install
93-
cd "$TARGET"
93+
cd $TARGET
9494
echo ">>> Great!Done! You can jump in "`pwd`
9595

9696
go mod init "$MODULE"

0 commit comments

Comments
 (0)