Skip to content

Commit 69f815c

Browse files
committed
docs: improve code documentation and comments across functions
- Remove redundant comments for `NewTask` and `Encode` functions - Add detailed comments for `Decode` function, including parameters and return values Signed-off-by: appleboy <[email protected]>
1 parent 24a13ca commit 69f815c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

job/job.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func NewMessage(m core.QueuedMessage, opts ...AllowOption) Message {
7878
}
7979
}
8080

81-
// NewTask create new task
8281
func NewTask(task TaskFunc, opts ...AllowOption) Message {
8382
o := NewOptions(opts...)
8483

@@ -93,7 +92,6 @@ func NewTask(task TaskFunc, opts ...AllowOption) Message {
9392
}
9493
}
9594

96-
// Encode for encoding the structure
9795
func Encode(m *Message) []byte {
9896
b, err := msgpack.Marshal(m)
9997
if err != nil {
@@ -103,7 +101,15 @@ func Encode(m *Message) []byte {
103101
return b
104102
}
105103

106-
// Decode for decoding the structure
104+
// Decode takes a byte slice and unmarshals it into a Message struct using msgpack.
105+
// If the unmarshalling process encounters an error, the function will panic.
106+
// It returns a pointer to the unmarshalled Message.
107+
//
108+
// Parameters:
109+
// - b: A byte slice containing the msgpack-encoded data.
110+
//
111+
// Returns:
112+
// - A pointer to the decoded Message struct.
107113
func Decode(b []byte) *Message {
108114
var msg Message
109115
err := msgpack.Unmarshal(b, &msg)

0 commit comments

Comments
 (0)