Skip to content

Commit

Permalink
Merge pull request #7 from Famcache/refactor/2.0.0-replies
Browse files Browse the repository at this point in the history
feat(reply): Categorize replies by flags

BREAKING CHANGE: Changed server reply protocol
  • Loading branch information
shahen94 authored Jun 28, 2024
2 parents 9dc68a8 + efa7db9 commit 43b9c8e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
2.0.0
13 changes: 9 additions & 4 deletions pkg/command/job_command_reply.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package command

import "net"
import (
"fmt"
"net"
)

const jobMark = "JOB"

func (q *JobCommand) ReplyOK(conn net.Conn, response string) {
message := q.ID() + " OK " + response + "\n"
message := fmt.Sprintf("%s %s OK %s\n", q.ID(), jobMark, response)

conn.Write([]byte(message))
}

func (q *JobCommand) ReplySuccess(conn net.Conn) {
message := q.ID() + " OK" + "\n"
message := fmt.Sprintf("%s %s OK\n", q.ID(), jobMark)

conn.Write([]byte(message))
}

func (q *JobCommand) ReplyError(conn net.Conn, response string) {
message := q.ID() + " ERROR: " + response + "\n"
message := fmt.Sprintf("%s %s ERROR %s\n", q.ID(), jobMark, response)

conn.Write([]byte(message))
}
13 changes: 9 additions & 4 deletions pkg/command/store_command_reply.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package command

import "net"
import (
"fmt"
"net"
)

const storeMark = "STORE"

func (q *StoreCommand) ReplyOK(conn net.Conn, response string) {
message := q.ID() + " OK " + response + "\n"
message := fmt.Sprintf("%s %s OK %s\n", q.ID(), storeMark, response)

conn.Write([]byte(message))
}

func (q *StoreCommand) ReplySuccess(conn net.Conn) {
message := q.ID() + " OK" + "\n"
message := fmt.Sprintf("%s %s OK\n", q.ID(), storeMark)

conn.Write([]byte(message))
}

func (q *StoreCommand) ReplyError(conn net.Conn, response string) {
message := q.ID() + " ERROR: " + response + "\n"
message := fmt.Sprintf("%s %s ERROR %s\n", q.ID(), storeMark, response)

conn.Write([]byte(message))
}

0 comments on commit 43b9c8e

Please sign in to comment.