Skip to content

Commit

Permalink
Merge pull request #192 from hooligan520/master
Browse files Browse the repository at this point in the history
update changelog
  • Loading branch information
hooligan520 authored Apr 23, 2020
2 parents 796b573 + 8a1a13e commit 71bf643
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 37 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.1.2 (2020/04/23)
### ChangLogs
- merge from tars internal version

## 1.1.1 (2020/04/06)
### ChangLogs
Expand Down
13 changes: 7 additions & 6 deletions tars/tools/Demo/Servant.tars
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module _APP_{
interface _SERVANT_{

int Add(int a,int b,out int c); // Some example function
int Sub(int a,int b,out int c); // Some example function
};
module _APP_
{
interface _SERVANT_
{
int Add(int a,int b,out int c); // Some example function
int Sub(int a,int b,out int c); // Some example function
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import (
"context"
)

// _SERVANT_Imp servant implementation
type _SERVANT_Imp struct {
}

func (imp *_SERVANT_Imp) Init() (int, error) {
// Init servant init
func (imp *_SERVANT_Imp) Init() (error) {
//initialize servant here:
//...
return 0,nil
return nil
}

//////////////////////////////////////////////////////
// Destroy servant destory
func (imp *_SERVANT_Imp) Destroy() {
//destroy servant here:
//...
Expand Down
15 changes: 0 additions & 15 deletions tars/tools/Demo/Server.go

This file was deleted.

File renamed without changes.
30 changes: 30 additions & 0 deletions tars/tools/Demo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"os"

"github.com/TarsCloud/TarsGo/tars"

"_APP_"
)

func main() {
// Get server config
cfg := tars.GetServerConfig()

// New servant imp
imp := new(_SERVANT_Imp)
err := imp.Init()
if err != nil {
fmt.Printf("_SERVANT_Imp init fail, err:(%s)\n", err)
os.Exit(-1)
}
// New servant
app := new(_APP_._SERVANT_)
// Register Servant
app.AddServantWithContext(imp, cfg.App+"."+cfg.Server+"._SERVANT_Obj")

// Run application
tars.Run()
}
2 changes: 1 addition & 1 deletion tars/tools/Demo/start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
make
./_SERVER_ --config=_SERVER_.conf
./_SERVER_ --config=config.conf
4 changes: 2 additions & 2 deletions tars/tools/Demo4GoMod/Servant_imp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ type _SERVANT_Imp struct {
}

// Init servant init
func (imp *_SERVANT_Imp) Init() (int, error) {
func (imp *_SERVANT_Imp) Init() (error) {
//initialize servant here:
//...
return 0,nil
return nil
}

// Destroy servant destory
Expand Down
4 changes: 2 additions & 2 deletions tars/tools/Demo4GoMod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func main() {

// New servant imp
imp := new(_SERVANT_Imp)
ret, err := imp.Init()
err := imp.Init()
if err != nil {
fmt.Printf("_SERVANT_Imp init fail, ret:%d, err:(%s)\n", ret, err)
fmt.Printf("_SERVANT_Imp init fail, err:(%s)\n", err)
os.Exit(-1)
}
// New servant
Expand Down
14 changes: 8 additions & 6 deletions tars/tools/create_tars_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ else
for FILE in $SRC_FILE client/client.go vendor/vendor.json debugtool/dumpstack.go
do
echo ">>>Now doing:"$FILE" >>>>"
sed -i "s/_APP_/$APP/g" $FILE
sed -i "s/_SERVER_/$SERVER/g" $FILE
sed -i "s/_SERVANT_/$SERVANT/g" $FILE
sed -i "s/_APP_/$APP/g" $FILE
sed -i "s/_SERVER_/$SERVER/g" $FILE
sed -i "s/_SERVANT_/$SERVANT/g" $FILE
done

SERVANT_LC=`echo $SERVANT|tr 'A-Z' 'a-z'`
for RENAMEFILE in `ls `
do
rename "Server" "$SERVER" $RENAMEFILE
rename "Servant" "$SERVANT" $RENAMEFILE
rename "Servant.tars" "${SERVANT}.tars" $RENAMEFILE
rename "Servant_imp.go" "${SERVANT_LC}_imp.go" $RENAMEFILE
done
fi

# try build tars2go
cd "$GOPATH/src/github.com/TarsCloud/TarsGo/tars/tools/tars2go"
cd "$SRC_DIR/tars2go"
go install
cd "$GOPATH/src/$APP/$SERVER"
cd $TARGET
echo ">>> Great!Done! You can jump in "`pwd`

# show tips: how to convert tars to golang
Expand Down
4 changes: 2 additions & 2 deletions tars/tools/create_tars_server_gomod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cp -r $DEBUGDIR $TARGET

if [ `uname` == "Darwin" ] # support macOS
then
for FILE in $SRC_FILE client/client.go
for FILE in $SRC_FILE client/client.go debugtool/dumpstack.go
do
echo ">>>Now doing:"$FILE" >>>>"
sed -i "" "s/_APP_/$APP/g" $FILE
Expand Down Expand Up @@ -90,7 +90,7 @@ fi
# try build tars2go
cd "$SRC_DIR/tars2go"
go install
cd "$TARGET"
cd $TARGET
echo ">>> Great!Done! You can jump in "`pwd`

go mod init "$MODULE"
Expand Down

0 comments on commit 71bf643

Please sign in to comment.