Skip to content

Commit 5c3b229

Browse files
Merged comments
2 parents 6fe135d + 62c2129 commit 5c3b229

File tree

3 files changed

+52
-32
lines changed

3 files changed

+52
-32
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ go:
66
- master
77

88
script:
9-
go test -v ./...
9+
- go test -v ./...
10+
- ./test.sh
11+
12+
after_success:
13+
- bash <(curl -s https://codecov.io/bash) -t 6e0ff3d8-4792-4b3e-aedf-c589ad356179

README.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
[![GoDoc](https://godoc.org/github.com/DistributedClocks/GoVector?status.svg)](https://godoc.org/github.com/DistributedClocks/GoVector)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/DistributedClocks/GoVector)](https://goreportcard.com/report/github.com/DistributedClocks/GoVector)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7-
7+
[![Coverage Status](https://img.shields.io/codecov/c/github/DistributedClocks/GoVector/master.svg)](https://codecov.io/gh/DistributedClocks/GoVector)
88

99

1010
GoVector is a vector clock logging library written in Go. The [vector
1111
clock algorithm](https://en.wikipedia.org/wiki/Vector_clock) is used
1212
to order events in distributed systems in the absence of a centralized
1313
clock. GoVector implements the vector clock algorithm and provides
14-
feature rich logging, and encoding infrastructure. Vector clock events
14+
feature rich logging, and encoding infrastructure.
15+
16+
Vector clock events
1517
are generated using 3 key functions `PrepareSend`, `UnpackReceive`,
1618
and `LogLocalEvent`. PrepareSend encodes messages for network
1719
transport, updates GoVectors local time, and logs a sending event.
@@ -24,12 +26,14 @@ This library can be added to a Go project to generate a
2426
timestamped log of events in a concurrent or distributed system.
2527
GoVector is compatible with Go 1.4+
2628

27-
* govec/ : Contains the Library and all its dependencies
28-
* example/ : Contains some examples instrumented with different features of GoVector
29+
* govec/ : Contains the Library and all its dependencies
30+
* govec/vclock : Pure vector clock library
31+
* govec/vrpc : Go's rpc with GoVector integration
32+
* example/ : Contains some examples instrumented with different features of GoVector
2933

30-
### Usage
34+
### Installation
3135

32-
To use GoVector you must have a correctly configured go development
36+
To install GoVector you must have a correctly configured go development
3337
environment, see [How to write Go
3438
Code](https://golang.org/doc/code.html)
3539

@@ -41,14 +45,7 @@ tool command:
4145
*gofmt* will automatically add imports for GoVector. If you do not
4246
have a working version of *gofmt* GoVector can be imported by adding:
4347

44-
See GoVectors library documentation
45-
[here](https://godoc.org/github.com/DistributedClocks/GoVector/govec).
46-
47-
- [ ] Write up priority example
48-
- [ ] Simple write up partial ordering
49-
- [ ] Write up limitations 1 process per machine
50-
51-
### Examples
48+
### Usage
5249

5350
The following is a basic example of how this library can be used
5451
```go
@@ -57,31 +54,41 @@ The following is a basic example of how this library can be used
5754
import "github.com/DistributedClocks/GoVector/govec"
5855

5956
func main() {
57+
//Initialize GoVector logger
6058
Logger := govec.InitGoVector("MyProcess", "LogFile")
6159

62-
//In Sending Process
63-
64-
//Prepare a Message
60+
//Encode message, and update vector clock
6561
messagepayload := []byte("samplepayload")
66-
finalsend := Logger.PrepareSend("Sending Message", messagepayload)
62+
vectorclockmessage := Logger.PrepareSend("Sending Message", messagepayload)
6763

6864
//send message
69-
connection.Write(finalsend)
65+
connection.Write(vectorclockmessage)
7066

7167
//In Receiving Process
72-
73-
//receive message
74-
recbuf := Logger.UnpackReceive("Receiving Message", finalsend)
68+
connection.Read(vectorclockmessage)
69+
//Decode message, and update local vector clock with received clock
70+
Logger.UnpackReceive("Receiving Message", &messagepayload, vectorclockmessage)
7571

76-
//Can be called at any point
72+
//Log a local event
7773
Logger.LogLocalEvent("Example Complete")
78-
79-
Logger.DisableLogging()
80-
//No further events will be written to log file
8174
}
8275
```
76+
For complete documentation and small examples see GoVectors [GoDoc](https://godoc.org/github.com/DistributedClocks/GoVector/govec),
77+
78+
### End to End Examples
79+
80+
* Client-Server GoVector insturmentation [Examples/ClientServer.go](example/ClientServer/ClientServer.go)
81+
* RPC Client-Server program [Examples/RpcClientServer.go](example/RpcClientServer/RpcClientServer.go)
82+
83+
### Motivation
84+
85+
GoVector was initially developed as a pedagogical tool for students attending UBC's computer science course on distributed systems (CPSC 416). Students new to the development of distributed systems can reason about event orderings by visualizing their executions with [ShiViz](http://bestchai.bitbucket.io/shiviz/). Furthermore GoVectors marshaling functionality reduces student effort in writing networking code which is largely boiler plate.
86+
87+
As a result of student requests GoVector transformed into a general purpose logging tool. Additional features include optimized IO, priority logging, [TSViz](https://bestchai.bitbucket.io/tsviz/) compatibility and RPC instrumentation.
88+
89+
### Output Example
8390

84-
This produces the log "LogFile.txt" :
91+
The source code from the useage example produces the following log into a file named "LogFile.txt" :
8592

8693
MyProcess {"MyProcess":1}
8794
Initialization Complete
@@ -92,11 +99,7 @@ This produces the log "LogFile.txt" :
9299
MyProcess {"MyProcess":4}
93100
Example Complete
94101

95-
An executable example of a similar program can be found in
96-
[Examples/ClientServer.go](example/ClientServer/ClientServer.go)
97102

98-
An executable example of a RPC Client-Server program can be found in
99-
[Examples/RpcClientServer.go](example/RpcClientServer/RpcClientServer.go)
100103

101104

102105
Here is a sample output of the priority logger

test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
echo "" > coverage.txt
5+
6+
for d in $(go list ./... | grep -v vendor); do
7+
go test -race -coverprofile=profile.out -covermode=atomic $d
8+
if [ -f profile.out ]; then
9+
cat profile.out >> coverage.txt
10+
rm profile.out
11+
fi
12+
done
13+

0 commit comments

Comments
 (0)