this project is a test project to build a message middleware for real time stock data publishing.
it will receive data sent from some stock data generator and push data to clients who have scribe it.
this project is writen in go, so you may need to set up the go environment first.
add docker deploy support recently.
- using " git clone git@github.com:Owen2015/gomsg.git" to clone the source in your go workspace in an appropriate package.
- Modify the "Dockerfile" in the "gomsg" directory, change the "WORKDIR" to your actual place.
- cd gomsg directory, build docker image using "docker build -t gomsg ."
- runing the service using "docker run -d -p 3000:3000 gomsg". That's it, docker really make things easier.
you may want to use docker deploy because it is much easier. But in case you don't want to do that, following below instructions to deploy manually.
- you need to download Go and install it, using "wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz" to download Go.
- install Go using "tar -C /usr/local -xzf go1.10.linux-amd64.tar.gz"
- export path environment variable using "export PATH=$PATH:/usr/local/go/bin" if something wrong happen, refer to Go's official website for more information. https://golang.org/doc/install
after you install Go environment, you need to set up a go workspace.
- find a suitable place for your go workspace and create a go workspace hierarchy using "mkdir -p go/bin","mkdir -p go/pkg", "mkdir -p go/src"
- set a go workspace environment varaible "GOPATH" using "set GOPATH YourGoWorkspace" and export environment varaible using "export PATH=$PATH:$GOPATH/bin"
if something wrong happen, refer to Go's offical website for more information. https://golang.org/doc/code.html
Since the project use a third part liberary gorrila, we need to install it. enter you go workspace and using command "go get github.com/gorilla/websocket" to install it.
- Enter your source directory of go workspace and download the project using "git@github.com:Owen2015/gomsg.git"
- You can change project's server port or request path by delve into main.go source file and change it. Since only a few lines in there, it will not be hard.
- Enter go workspace and using "go install yourpackagepath/gomsg" to install it.
- Now there should be a gomsg executable file in you bin folder. Using "./bin/gomsg" to run it
- Open browser and enter "http://localhost:3000/" and you can access the stock data in real time.