Skip to content

Commit a38753d

Browse files
committed
Merge branch 'v0.10.0' of https://github.com/spaceuptech/space-cloud into ee-v0.10
2 parents e588236 + 6ab8c02 commit a38753d

File tree

12 files changed

+16
-8
lines changed

12 files changed

+16
-8
lines changed

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type CrudStub struct {
3939
Conn string `json:"conn" yaml:"conn"`
4040
Collections map[string]*TableRule `json:"collections" yaml:"collections"` // The key here is table name
4141
IsPrimary bool `json:"isPrimary" yaml:"isPrimary"`
42+
Enabled bool `json:"enabled" yaml:"enabled"`
4243
}
4344

4445
// TableRule contains the config at the collection level

config/template.go

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ secret: some-secret
66
modules:
77
crud:
88
{{.PrimaryDB}}:
9+
enabled: true
910
conn: {{.Conn}}
1011
isPrimary: true
1112
collections:

examples/basic-todo-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ secret: some-secret
44
modules:
55
crud:
66
mongo:
7+
enabled: true
78
conn: mongodb://localhost:27017
89
collections:
910
todos:

examples/realtime-monitoring-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ modules:
1717
rule: allow
1818
crud:
1919
sql-mysql:
20+
enabled: true
2021
conn: root:my-secret-pw@/test_database
2122
isPrimary: true
2223
collections:

examples/realtime-todo-app/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ secret: some-secret
44
modules:
55
crud:
66
mongo:
7+
enabled: true
78
conn: mongodb://localhost:27017
89
isPrimary: true
910
collections:

modules/crud/crud.go

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func (m *Module) SetConfig(crud config.Crud) error {
8484

8585
// Create a new crud blocks
8686
for k, v := range crud {
87+
// Skip this block if it is not enabled
88+
if !v.Enabled {
89+
continue
90+
}
91+
8792
c, err := initBlock(utils.DBType(k), v.Conn)
8893
if err != nil {
8994
return errors.New("CURD: Error - " + k + " could not be initialised")

modules/crud/mgo/aggregate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ func (m *Mongo) Aggregate(ctx context.Context, project, col string, req *model.A
1717
var result map[string]interface{}
1818

1919
cur, err := collection.Aggregate(ctx, req.Pipeline)
20-
defer cur.Close(ctx)
2120
if err != nil {
2221
return nil, err
2322
}
23+
defer cur.Close(ctx)
2424

2525
if !cur.Next(ctx) {
2626
return nil, errors.New("No result found")

modules/crud/mgo/read.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ func (m *Mongo) Read(ctx context.Context, project, col string, req *model.ReadRe
5858

5959
results := []interface{}{}
6060
cur, err := collection.Find(ctx, req.Find, findOptions)
61-
defer cur.Close(ctx)
6261
if err != nil {
6362
return nil, err
6463
}
64+
defer cur.Close(ctx)
6565

6666
// Finding multiple documents returns a cursor
6767
// Iterating through the cursor allows us to decode documents one at a time

modules/realtime/routine.go

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (m *Module) worker() {
5252
// Get the feedData
5353
req := tempReq.(*pendingRequest)
5454
m.helperSendFeed(req.data)
55+
m.pendingRequests.Delete(msg.ID)
5556
}
5657
}
5758

utils/client/grpc_realtime.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func (c *GRPCRealtimeClient) RoutineWrite() {
5858
// Write wrties the object to the client
5959
func (c *GRPCRealtimeClient) Write(res *model.Message) {
6060
select {
61-
case c.channel <- res:
6261
case <-c.ctx.Done():
62+
case c.channel <- res:
6363
}
6464
}
6565

@@ -74,7 +74,6 @@ func (c *GRPCRealtimeClient) Read(cb DataCallback) {
7474
for {
7575
in, err := c.stream.Recv()
7676
if err != nil {
77-
log.Println("GRPC Error -", err)
7877
return
7978
}
8079
data := make(map[string]interface{})

utils/client/grpc_service.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func (c *GRPCServiceClient) RoutineWrite() {
2626
case utils.TypeServiceRequest:
2727
reqMsg, ok := res.Data.(*model.FunctionsPayload)
2828
if !ok {
29-
log.Println("GRPC Service Error - Invalid data type", res.Data)
3029
break
3130
}
3231

@@ -63,8 +62,8 @@ func (c *GRPCServiceClient) RoutineWrite() {
6362
// Write wrties the object to the client
6463
func (c *GRPCServiceClient) Write(res *model.Message) {
6564
select {
66-
case c.channel <- res:
6765
case <-c.ctx.Done():
66+
case c.channel <- res:
6867
}
6968
}
7069

@@ -80,7 +79,7 @@ func (c *GRPCServiceClient) Read(cb DataCallback) {
8079
in, err := c.streamServer.Recv()
8180
if err != nil {
8281
if err != nil {
83-
log.Println("GRPC Service Error -", err)
82+
log.Println("GRPC Service Receive Error -", err)
8483
return
8584
}
8685
}

utils/client/websocket.go

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func (c *WebsocketClient) Read(cb DataCallback) {
5050
data := &model.Message{}
5151
err := c.socket.ReadJSON(data)
5252
if err != nil {
53-
log.Println(err)
5453
return
5554
}
5655

0 commit comments

Comments
 (0)