Skip to content

Commit 09414b4

Browse files
committed

File tree

6 files changed

+121
-129
lines changed

6 files changed

+121
-129
lines changed

polycode/apiserver.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package polycode
33
import (
44
"fmt"
55
"github.com/gin-gonic/gin"
6+
"log"
67
"net/http"
78
)
89

@@ -26,27 +27,27 @@ func invokeHealthCheck(c *gin.Context) {
2627
}
2728

2829
func invokeApiHandler(c *gin.Context) {
29-
println("client: api request received")
30+
log.Println("client: api request received")
3031
var input ApiStartEvent
3132
if err := c.ShouldBindJSON(&input); err != nil {
3233
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
3334
return
3435
}
3536

36-
output := runTask(c, input)
37-
println("client: api request completed")
37+
output := runApi(c, input)
38+
log.Println("client: api request completed")
3839
c.JSON(http.StatusOK, output)
3940
}
4041

4142
func invokeServiceHandler(c *gin.Context) {
42-
println("client: service request received")
43+
log.Println("client: service request received")
4344
var input TaskStartEvent
4445
if err := c.ShouldBindJSON(&input); err != nil {
4546
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
4647
return
4748
}
4849

4950
output := runTask(c, input)
50-
println("client: service request completed")
51+
log.Println("client: service request completed")
5152
c.JSON(http.StatusOK, output)
5253
}

polycode/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"log"
78
"net/http"
89
"time"
910
)
@@ -142,7 +143,7 @@ func (sc *ServiceClient) PutFile(sessionId string, req PutFileRequest) error {
142143
}
143144

144145
func executeApiWithoutResponse(httpClient *http.Client, baseUrl string, sessionId string, path string, req any) error {
145-
println(fmt.Sprintf("client: exec api without response from %s with session id %s", path, sessionId))
146+
log.Printf("client: exec api without response from %s with session id %s", path, sessionId)
146147

147148
reqBody, err := json.Marshal(req)
148149
if err != nil {
@@ -170,7 +171,7 @@ func executeApiWithoutResponse(httpClient *http.Client, baseUrl string, sessionI
170171
}
171172

172173
func executeApiWithResponse[T any](httpClient *http.Client, baseUrl string, sessionId string, path string, req any, res *T) error {
173-
println(fmt.Sprintf("client: exec api with response from %s with session id %s", path, sessionId))
174+
log.Printf("client: exec api with response from %s with session id %s\n", path, sessionId)
174175

175176
reqBody, err := json.Marshal(req)
176177
if err != nil {

polycode/errors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (t Error) With(args ...any) Error {
5555

5656
func (t Error) Error() string {
5757
if t.CauseBy == "" {
58-
5958
return fmt.Sprintf("module: [%s], errorNo : [%d], reason: [%s]", t.Module, t.ErrorNo, fmt.Sprintf(t.Format, t.Args...))
6059
} else {
6160
return fmt.Sprintf("module: [%s], errorNo : [%d], reason: [%s], causeBy: [%s]", t.Module, t.ErrorNo, fmt.Sprintf(t.Format, t.Args...), t.CauseBy)

polycode/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package polycode
33
import (
44
"context"
55
"encoding/json"
6+
"log"
67
)
78

89
// Order is used for specifying the order of results.
@@ -130,20 +131,19 @@ func (q Query) All(ctx context.Context, ret interface{}) error {
130131
}
131132
r, err := q.collection.client.QueryItems(q.collection.sessionId, req)
132133
if err != nil {
133-
println("error queryitem ", err.Error())
134+
log.Println("client: error query item ", err.Error())
134135
return err
135136
}
136137

137138
b, err := json.Marshal(r)
138139
if err != nil {
139-
println("error marshal queryitem ", err.Error())
140+
log.Println("client: error marshal query item ", err.Error())
140141
return err
141142
}
142143

143-
println("query all ", string(b))
144144
err = json.Unmarshal(b, ret)
145145
if err != nil {
146-
println("error unmarshal queryitem ", err.Error())
146+
log.Println("client: error unmarshal query item ", err.Error())
147147
return err
148148
}
149149
return nil

polycode/remote.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package polycode
22

33
import (
44
"encoding/json"
5-
"fmt"
65
)
76

87
type Future interface {
@@ -28,7 +27,6 @@ func (e ErrorFuture) IsNull() bool {
2827
}
2928

3029
func (e ErrorFuture) Get(ret any) error {
31-
println(fmt.Sprintf("future data %v\n", e.error))
3230
return e.error
3331
}
3432

@@ -45,7 +43,6 @@ func (f FutureImpl) IsNull() bool {
4543
}
4644

4745
func (f FutureImpl) Get(ret any) error {
48-
println(fmt.Sprintf("future data %v\n", f.data))
4946
switch ret.(type) {
5047
case map[string]interface{}:
5148
{
@@ -60,7 +57,6 @@ func (f FutureImpl) Get(ret any) error {
6057
switch ret.(type) {
6158
case *string:
6259
{
63-
println("string type found")
6460
*ret.(*string) = string(b)
6561
return nil
6662
}
@@ -93,6 +89,5 @@ func (n NullFutureImpl) IsNull() bool {
9389
}
9490

9591
func (n NullFutureImpl) Get(ret any) error {
96-
println("future data is null\n")
9792
return nil
9893
}

0 commit comments

Comments
 (0)