Skip to content

Commit

Permalink
Run make fmt to format the code according to Go standard
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Feb 26, 2020
1 parent a31b8f8 commit c095c58
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 47 deletions.
8 changes: 4 additions & 4 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ func ToOperations(operations []operation.Operation) []*api.Operation {
case *operation.Select:
pbOperation.Body = &api.Operation_Select_{
Select: &api.Operation_Select{
ParentCreatedAt: toTimeTicket(op.ParentCreatedAt()),
From: toTextNodePos(op.From()),
To: toTextNodePos(op.To()),
ExecutedAt: toTimeTicket(op.ExecutedAt()),
ParentCreatedAt: toTimeTicket(op.ParentCreatedAt()),
From: toTextNodePos(op.From()),
To: toTextNodePos(op.To()),
ExecutedAt: toTimeTicket(op.ExecutedAt()),
},
}
default:
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func TestClientAndDocument(t *testing.T) {
defer wg.Done()
rch := c1.Watch(ctx, doc1)

resp := <- rch
resp := <-rch
if resp.Err == io.EOF {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/document/change/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewContext(id *ID, message string, root *json.Root) *Context {
return &Context{
id: id,
message: message,
root: root,
root: root,
}
}

Expand Down
10 changes: 4 additions & 6 deletions pkg/document/json/rht.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
)

type rhtNode struct {
key string
elem Element
key string
elem Element
}

func newRHTNode(key string, elem Element) *rhtNode {
return &rhtNode{
key: key,
elem: elem,
key: key,
elem: elem,
}
}

Expand All @@ -31,7 +31,6 @@ func (n *rhtNode) isDeleted() bool {
return n.elem.DeletedAt() != nil
}


// RHT is replicated hash table.
type RHT struct {
nodeQueueMapByKey map[string]*pq.PriorityQueue
Expand Down Expand Up @@ -128,4 +127,3 @@ func (rht *RHT) AllNodes() []*rhtNode {

return nodes
}

16 changes: 8 additions & 8 deletions pkg/document/operation/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
)

type Select struct {
parentCreatedAt *time.Ticket
from *json.TextNodePos
to *json.TextNodePos
executedAt *time.Ticket
parentCreatedAt *time.Ticket
from *json.TextNodePos
to *json.TextNodePos
executedAt *time.Ticket
}

func NewSelect(
Expand All @@ -22,10 +22,10 @@ func NewSelect(
executedAt *time.Ticket,
) *Select {
return &Select{
parentCreatedAt: parentCreatedAt,
from: from,
to: to,
executedAt: executedAt,
parentCreatedAt: parentCreatedAt,
from: from,
to: to,
executedAt: executedAt,
}
}

Expand Down
9 changes: 4 additions & 5 deletions pkg/pq/priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ type PQValue interface {

// PQItem is something we manage in a priority queue.
type PQItem struct {
value PQValue
index int
value PQValue
index int
}


func NewPQItem(value PQValue) *PQItem {
return &PQItem{
value: value,
index: -1,
value: value,
index: -1,
}
}

Expand Down
42 changes: 21 additions & 21 deletions yorkie/api/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ func (s *RPCServer) AttachDocument(
}

// if pack.HasChanges() {
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
}()
}()
// }

clientInfo, docInfo, err := clients.FindClientAndDocument(ctx, s.backend, req.ClientId, pack)
Expand Down Expand Up @@ -139,14 +139,14 @@ func (s *RPCServer) DetachDocument(
}

// if pack.HasChanges() {
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
}()
}()
// }

clientInfo, docInfo, err := clients.FindClientAndDocument(ctx, s.backend, req.ClientId, pack)
Expand Down Expand Up @@ -186,14 +186,14 @@ func (s *RPCServer) PushPull(

// TODO uncomment write lock condition. We need $max operation on client.
// if pack.HasChanges() {
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
if err := s.backend.Lock(pack.DocumentKey.BSONKey()); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
defer func() {
if err := s.backend.Unlock(pack.DocumentKey.BSONKey()); err != nil {
log.Logger.Error(err)
}
}()
}()
// }

clientInfo, docInfo, err := clients.FindClientAndDocument(ctx, s.backend, req.ClientId, pack)
Expand Down
2 changes: 1 addition & 1 deletion yorkie/backend/mongo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (c *Client) CreateChangeInfos(

for _, c := range changes {
modelChanges = append(modelChanges, mongo.NewUpdateOneModel().SetFilter(bson.M{
"doc_id": docID,
"doc_id": docID,
"server_seq": c.ServerSeq(),
}).SetUpdate(bson.M{"$set": bson.M{
"actor": types.EncodeActorID(c.ID().Actor()),
Expand Down

0 comments on commit c095c58

Please sign in to comment.