Skip to content

Commit d264d32

Browse files
fought with linter
1 parent 5b147d7 commit d264d32

File tree

3 files changed

+59
-56
lines changed

3 files changed

+59
-56
lines changed

example/MessagePack/MessagePackTests.go

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

33
import (
44
"fmt"
5+
56
"github.com/DistributedClocks/GoVector/govec/vclock"
67
"github.com/vmihailenco/msgpack"
78
)
@@ -15,6 +16,7 @@ type ClockPayload struct {
1516
var _ msgpack.CustomEncoder = (*ClockPayload)(nil)
1617
var _ msgpack.CustomDecoder = (*ClockPayload)(nil)
1718

19+
//EncodeMsgpack is a custom encoder function, needed for msgpack interoperability
1820
func (d *ClockPayload) EncodeMsgpack(enc *msgpack.Encoder) error {
1921

2022
var err error
@@ -51,6 +53,8 @@ func (d *ClockPayload) EncodeMsgpack(enc *msgpack.Encoder) error {
5153

5254
}
5355

56+
//DecodeMsgpack is a custom decoder function, needed for msgpack
57+
//interoperability
5458
func (d *ClockPayload) DecodeMsgpack(dec *msgpack.Decoder) error {
5559

5660
var err error

govec/govec.go

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//GoVector vector clock logging library
1+
//Package govec is a vector clock logging library
22
package govec
33

44
import (
@@ -76,7 +76,8 @@ type GoLogConfig struct {
7676
Priority LogPriority
7777
}
7878

79-
//Returns the default GoLogConfig with default values for various fields.
79+
//GetDefaultConfig returns the default GoLogConfig with default values
80+
//for various fields.
8081
func GetDefaultConfig() GoLogConfig {
8182
config := GoLogConfig{
8283
Buffered: false,
@@ -88,29 +89,29 @@ func GetDefaultConfig() GoLogConfig {
8889
return config
8990
}
9091

91-
//This is the data structure that is actually end on the wire
92+
//VClockPayload is the data structure that is actually end on the wire
9293
type VClockPayload struct {
9394
Pid string
9495
VcMap map[string]uint64
9596
Payload interface{}
9697
}
9798

98-
//Prints the Data Stuct as Bytes
99+
//PrintDataBytes prints the Data Stuct as Bytes
99100
func (d *VClockPayload) PrintDataBytes() {
100101
fmt.Printf("%x \n", d.Pid)
101102
fmt.Printf("%X \n", d.VcMap)
102103
fmt.Printf("%X \n", d.Payload)
103104
}
104105

105-
//Prints the Data Struct as a String
106+
//String returns VClockPayload's pid as a string
106107
func (d *VClockPayload) String() (s string) {
107108
s += "-----DATA START -----\n"
108109
s += string(d.Pid[:])
109110
s += "-----DATA END -----\n"
110111
return
111112
}
112113

113-
/* Custom encoder function, needed for msgpack interoperability */
114+
//EncodeMsgpack is a custom encoder function, needed for msgpack interoperability
114115
func (d *VClockPayload) EncodeMsgpack(enc *msgpack.Encoder) error {
115116

116117
var err error
@@ -147,7 +148,8 @@ func (d *VClockPayload) EncodeMsgpack(enc *msgpack.Encoder) error {
147148

148149
}
149150

150-
/* Custom decoder function, needed for msgpack interoperability */
151+
//DecodeMsgpack is a custom decoder function, needed for msgpack
152+
//interoperability
151153
func (d *VClockPayload) DecodeMsgpack(dec *msgpack.Decoder) error {
152154
var err error
153155

@@ -324,7 +326,7 @@ func (gv *GoLog) prepareLogFile() {
324326
}
325327
}
326328

327-
//Returns the current vector clock
329+
//GetCurrentVC returns the current vector clock
328330
func (gv *GoLog) GetCurrentVC() vclock.VClock {
329331
return gv.currentVC
330332
}
@@ -347,26 +349,28 @@ func defaultDecoder(buf []byte, payload interface{}) error {
347349
return msgpack.Unmarshal(buf, payload)
348350
}
349351

350-
//Enables buffered writes to the log file. All the log messages are only written
351-
//to the LogFile via an explicit call to the function Flush.
352-
//Note: Buffered writes are automatically disabled.
352+
//EnableBufferedWrites enables buffered writes to the log file. All
353+
//the log messages are only written to the LogFile via an explicit
354+
//call to the function Flush. Note: Buffered writes are automatically
355+
//disabled.
353356
func (gv *GoLog) EnableBufferedWrites() {
354357
gv.buffered = true
355358
}
356359

357-
//Disables buffered writes to the log file. All the log messages from now on
358-
//will be written to the Log file immediately. Writes all the existing
359-
//log messages that haven't been written to Log file yet.
360+
//DisableBufferedWrites disables buffered writes to the log file. All
361+
//the log messages from now on will be written to the Log file
362+
//immediately. Writes all the existing log messages that haven't been
363+
//written to Log file yet.
360364
func (gv *GoLog) DisableBufferedWrites() {
361365
gv.buffered = false
362366
if gv.output != "" {
363367
gv.Flush()
364368
}
365369
}
366370

367-
//Writes the log messages stored in the buffer to the Log File. This
368-
//function should be used by the application to also force writes in
369-
//the case of interrupts and crashes. Note: Calling Flush when
371+
//Flush writes the log messages stored in the buffer to the Log File.
372+
//This function should be used by the application to also force writes
373+
//in the case of interrupts and crashes. Note: Calling Flush when
370374
//BufferedWrites is disabled is essentially a no-op.
371375
func (gv *GoLog) Flush() bool {
372376
complete := true
@@ -446,16 +450,17 @@ func (gv *GoLog) tickClock() {
446450
gv.currentVC.Tick(gv.pid)
447451
}
448452

449-
//Increments current vector timestamp and logs it into Log File.
450-
//* LogMessage (string) : Message to be logged
453+
//LogLocalEvent Increments current vector timestamp and logs it into
454+
//Log File. * LogMessage (string) : Message to be logged
451455
func (gv *GoLog) LogLocalEvent(Message string) (logSuccess bool) {
452456
return gv.LogLocalEventWithPriority(Message, gv.priority)
453457
}
454458

455-
//If the priority of the logger is lower than or equal to the priority
456-
//of this event then the current vector timestamp is incremented and the
457-
//message is logged it into the Log File. A color coded string is also
458-
//printed on the console.
459+
//LogLocalEventWithPriority implements LogLocalEvent with priority
460+
//levels. If the priority of the logger is lower than or equal to the
461+
//priority of this event then the current vector timestamp is
462+
//incremented and the message is logged it into the Log File. A color
463+
//coded string is also printed on the console.
459464
//* LogMessage (string) : Message to be logged
460465
//* Priority (LogPriority) : Priority at which the message is to be logged
461466
func (gv *GoLog) LogLocalEventWithPriority(LogMessage string, Priority LogPriority) (logSuccess bool) {
@@ -470,17 +475,15 @@ func (gv *GoLog) LogLocalEventWithPriority(LogMessage string, Priority LogPriori
470475
return
471476
}
472477

473-
/*
474-
This function is meant to be used immediately before sending.
475-
LogMessage will be logged along with the time of the send
476-
buf is encode-able data (structure or basic type)
477-
Returned is an encoded byte array with logging information.
478-
479-
This function is meant to be called before sending a packet. Usually,
480-
it should Update the Vector Clock for its own process, package with
481-
the clock using gob support and return the new byte array that should
482-
be sent onwards using the Send Command
483-
*/
478+
//PrepareSendWithPriority is meant to be used immediately before sending.
479+
//LogMessage will be logged along with the time of the send
480+
//buf is encode-able data (structure or basic type)
481+
//Returned is an encoded byte array with logging information.
482+
//
483+
//This function is meant to be called before sending a packet. Usually,
484+
//it should Update the Vector Clock for its own process, package with
485+
//the clock using gob support and return the new byte array that should
486+
//be sent onwards using the Send Command
484487
func (gv *GoLog) PrepareSendWithPriority(mesg string, buf interface{}, Priority LogPriority) (encodedBytes []byte) {
485488

486489
//Converting Vector Clock from Bytes and Updating the gv clock
@@ -505,17 +508,15 @@ func (gv *GoLog) PrepareSendWithPriority(mesg string, buf interface{}, Priority
505508
return
506509
}
507510

508-
/*
509-
This function is meant to be used immediately before sending.
510-
LogMessage will be logged along with the time of the send
511-
buf is encode-able data (structure or basic type)
512-
Returned is an encoded byte array with logging information.
513-
514-
This function is meant to be called before sending a packet. Usually,
515-
it should Update the Vector Clock for its own process, package with
516-
the clock using gob support and return the new byte array that should
517-
be sent onwards using the Send Command
518-
*/
511+
//PrepareSend is meant to be used immediately before sending.
512+
//LogMessage will be logged along with the time of the send
513+
//buf is encode-able data (structure or basic type)
514+
//Returned is an encoded byte array with logging information.
515+
//
516+
//This function is meant to be called before sending a packet. Usually,
517+
//it should Update the Vector Clock for its own process, package with
518+
//the clock using gob support and return the new byte array that should
519+
//be sent onwards using the Send Command
519520
func (gv *GoLog) PrepareSend(mesg string, buf interface{}) []byte {
520521
return gv.PrepareSendWithPriority(mesg, buf, gv.priority)
521522
}
@@ -529,16 +530,14 @@ func (gv *GoLog) mergeIncomingClock(mesg string, e VClockPayload, Priority LogPr
529530
gv.logWriteWrapper(mesg, "Something went Wrong, Could not Log!", Priority)
530531
}
531532

532-
/*
533-
UnpackReceive is used to unmarshall network data into local structures.
534-
LogMessage will be logged along with the vector time the receive happened
535-
buf is the network data, previously packaged by PrepareSend unpack is
536-
a pointer to a structure, the same as was packed by PrepareSend
537-
538-
This function is meant to be called immediately after receiving
539-
a packet. It unpacks the data by the program, the vector clock. It
540-
updates vector clock and logs it. and returns the user data
541-
*/
533+
//UnpackReceiveWithPriority is used to unmarshall network data into local structures.
534+
//LogMessage will be logged along with the vector time the receive happened
535+
//buf is the network data, previously packaged by PrepareSend unpack is
536+
//a pointer to a structure, the same as was packed by PrepareSend
537+
//
538+
//This function is meant to be called immediately after receiving
539+
//a packet. It unpacks the data by the program, the vector clock. It
540+
//updates vector clock and logs it. and returns the user data
542541
func (gv *GoLog) UnpackReceiveWithPriority(mesg string, buf []byte, unpack interface{}, Priority LogPriority) {
543542

544543
gv.mutex.Lock()

govec/govec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
//"fmt"
66
)
77

8-
var TestPID string = "TestPID"
8+
var TestPID = "TestPID"
99

1010
func TestBasicInit(t *testing.T) {
1111

0 commit comments

Comments
 (0)