goshare

package module
v0.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2015 License: MIT Imports: 21 Imported by: 4

README

Go Share

                        __
   ____ _____     _____/ /_  ____ _________
  / __ `/ __ \   / ___/ __ \/ __ `/ ___/ _ \
 / /_/ / /_/ /  (__  ) / / / /_/ / /  /  __/
 \__, /\____/  /____/_/ /_/\__,_/_/   \___/
/____/

Tasks in Queue at Trello Board

distributed under MIT License

Go Share any data among the nodes. Over HTTP or ZeroMQ.
  • GOShare eases up communication over HTTP GET param based interaction.
  • ZeroMQ REQ/REP based synchronous communication model.

it's "go get"-able

go get "github.com/abhishekkr/goshare"


Make Distributable Binary
./go-tasks.sh bin

This will create two distributable binaries ./bin/goshare_service & ./bin/goshare_daemon. Here ./bin/goshare_service works as shown in README's 'Tryout' section.

Whereas ./bin/goshare_daemon can be used as a system service daemon, with following command line flags (along with flags mentioned in 'Tryout' section for ports and db-path)

  • start: ./bin/goshare_daemon -daemon=start
  • stop: ./bin/goshare_daemon -daemon=stop
  • status: ./bin/goshare_daemon -daemon=status

this dumps daemon's current status to /tmp/goshare_daemon.status and pid to /tmp/goshare_daemon.pid the status and pid file path can be changed with flags '-daemon-log=' & '-daemon-pid=' respectively

Tryout:
 go run zxtra/goshare_daemon.go -dbpath=/tmp/GOTSDB

By default it runs HTTP daemon at port 9999 and ZeroMQ daemon at 9797/9898, make it run on another port using following required flags

 go run zxtra/goshare_daemon.go -dbpath=/tmp/GOTSDB -port=8080 -req-port=8000 -rep-port=8001
  Dummy Clients Using It

  * go run zxtra/gohttp_client.go

  * go run zxtra/go0mq_client.go


  for custom Port: 8080 for HTTP; Port: 8000/8001 for ZeroMQ

  * go run zxtra/gohttp_client.go -port=8080

  * go run zxtra/go0mq_client.go -req-port=8000 -rep-port=8001

To utilize it "zxtra/gohttp_client.go" and "zxtra/go0mq_client.go" can be referred on how to utilize capabilities of GoShare.


Structure:

"goshare"'s methods to adapt these in your code:

  • GoShare() : it runs HTTP and ZeroMQ daemon in parallel goroutines

has optional flags customization of:

  • dbpath: path for LevelDB (default: /tmp/GO.DB)
  • port: port to bind HTTP daemon (default: 9999)
  • req-port, rep-port: ports to bind ZeroMQ REQ/REP daemon (default: 9797, 9898)
  • GoShareHTTP(<levigo DB handle>, <http port as int>) : it runs HTTP daemon

  • GoShareZMQ(<levigo DB handle>, <req-port as int>, <rep-port as int>) : it runs ZMQ daemon


Now visit the the link asked by it and get the help page.

Dependency
  • go lang (obviously, the heart and soul of the app)
  • leveldb (we are using for datastore, it's awesome)
  • levigo (the go library utilized to access leveldb)
  • zeroMQ (the supercharged Sockets giving REQuest/REPly power)
  • gozmq GoLang ZeroMQ Bindings used here
  • levigoNS NameSpace KeyVal capabilities around leveldb via levigo
  • levigoTSDS TimeSeries KeyVal capabilties around leveldb via levigoNS
  • gol Set of common utility functionalities

baby-gopher

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBRest

func DBRest(httpMethod string, w http.ResponseWriter, req *http.Request)

DBRest enables HTTP to formulate DBTasks call from HTTP Request.

func DBRestHandler

func DBRestHandler(w http.ResponseWriter, req *http.Request)

DBRestHandler handles DB Call for HTTP Request Method at '/db'.

func DBRestResponse

func DBRestResponse(w http.ResponseWriter, req *http.Request, responseBytes []byte, axnStatus bool)

DBRestResponse sends proper response back to client based on success, data or error.

func DBTasks

func DBTasks(packetArray []string) ([]byte, bool)

DBTasks can be provided standard Packet Data Array from any communication Protocol. Communications handled on byte streams can use it by passing standard-ized packet-array It prepares Packet and passes on to TasksOnPacket. 0MQ directly utilizes it.

func DBTasksOnPacket

func DBTasksOnPacket(packet Packet) ([]byte, bool)

DBTasksOnPacket can utilize fromulated Packet. Communication can directly create packet and pass it here. HTTP directly utilizes it directly. 0MQ indirectly.

func DelKey

func DelKey(key string) bool

DelKey deletes val for a given key, returns status.

func DelKeyNS

func DelKeyNS(key string) bool

DelKeyNS deletes given key's namespace and all its values, returns status.

func DelKeyTSDS

func DelKeyTSDS(key string) bool

DelKeyTSDS deletes all keys under given namespace, same as NS. As here TimeSeries is a NameSpace

func DeleteFromPacket

func DeleteFromPacket(packet Packet) bool

DeleteFromPacket can handle multi-keys delete action, it acts on packet data.

func DoYouWannaContinue

func DoYouWannaContinue()

DoYouWannaContinue checking if you still wanna keep the goshare up.

func GetDeleteKey

func GetDeleteKey(w http.ResponseWriter, req *http.Request)

GetDeleteKey HTTP GET DB-POST call handler at 'del'.

func GetPushKey

func GetPushKey(w http.ResponseWriter, req *http.Request)

GetPushKey HTTP GET DB-POST call handler at '/put'.

func GetReadKey

func GetReadKey(w http.ResponseWriter, req *http.Request)

GetReadKey HTTP GET DB-GET call handler at '/get'.

func GoShare

func GoShare()

GoShare is daddy-o of goshare instance.

func GoShareEngine

func GoShareEngine(config Config)

GoShareEngine putting together base engine for GoShare as per config. dbpath, server_uri, httpport, rep_port, *string

func GoShareHTTP

func GoShareHTTP(httpuri string, httpport int)

GoShareHTTP handles all valid HTTP Requests for DBTasks, documentation and playground(WIP).

func GoShareZMQ

func GoShareZMQ(ip string, replyPorts []int)

GoShareZMQ starts a Daemon communicating of provided array ports over ZMQ Reply.

func PrefixKeyParentNamespace

func PrefixKeyParentNamespace(packet *Packet)

PrefixKeyParentNamespace prefixes Parent Namespaces to all keys in List if val for 'parentNamespace'.

func PrefixKeyValParentNamespace

func PrefixKeyValParentNamespace(packet *Packet)

PrefixKeyValParentNamespace prefixes Parent Namespaces to all key-val in HashMap if it has val for 'parentNamespace'.

func PushFromPacket

func PushFromPacket(packet Packet) bool

PushFromPacket handles push task based on provided Packet.

func PushKeyVal

func PushKeyVal(key string, val string) bool

PushKeyVal pushes a given set of Key-Val.

func PushKeyValNS

func PushKeyValNS(key string, val string) bool

PushKeyValNS pushes a given Namespace-Key and its value.

func PushKeyValNowTSDS

func PushKeyValNowTSDS(key string, val string) bool

PushKeyValNowTSDS pushes a key namespace-d with current time.

func PushKeyValTSDS

func PushKeyValTSDS(packet Packet) bool

PushKeyValTSDS pushes a key namespace-d with goltime.Timestamp.

func ReadFromPacket

func ReadFromPacket(packet Packet) string

ReadFromPacket calls ReadFuncByKeyType for multi-keys based on provided packet.

func ReadKey

func ReadKey(key string) golhashmap.HashMap

ReadKey gets value of given key.

func ReadKeyNS

func ReadKeyNS(key string) golhashmap.HashMap

ReadKeyNS gets value for all descendents of given key's namespace.

func ReadKeyTSDS

func ReadKeyTSDS(key string) golhashmap.HashMap

ReadKeyTSDS gets value for the asked time-frame key, aah same NS.

Types

type Config

type Config map[string]string

Config is a hashmap used here to carry around param=paramValue for GoShare.

func ConfigFromFlags

func ConfigFromFlags() Config

ConfigFromFlags configs from values provided to flags.

type FunkAxnParamKey

type FunkAxnParamKey func(key string) bool

FunkAxnParamKey is a function type which get passed one string parameter and returns one boolean. Like Del Key tasks.

func DeleteFuncByKeyType

func DeleteFuncByKeyType(keyType string) FunkAxnParamKey

DeleteFuncByKeyType calls a delete action for a key based on task-type.

type FunkAxnParamKeyReturnMap

type FunkAxnParamKeyReturnMap func(key string) golhashmap.HashMap

FunkAxnParamKeyReturnMap is a function type which get passed one string parameters and returns one hashmap. Like Get Key tasks.

func ReadFuncByKeyType

func ReadFuncByKeyType(keyType string) FunkAxnParamKeyReturnMap

ReadFuncByKeyType calls a read task on task-type.

type FunkAxnParamKeyVal

type FunkAxnParamKeyVal func(key string, val string) bool

FunkAxnParamKeyVal is a function type which get passed two string parameters and returns one boolean. Like Push Key-Val calls.

func PushFuncByKeyType

func PushFuncByKeyType(keyType string) FunkAxnParamKeyVal

PushFuncByKeyType returns func handle according to KeyType.

type Packet

type Packet struct {
	DBAction string
	TaskType string

	KeyType string // key: default, namespace key: ns, timeseries key: tsds, timeseries for goshare time: now
	ValType string // single: default, csv, json

	HashMap golhashmap.HashMap
	KeyList []string

	ParentNS string // allowed for ns|tsds|now
	TimeDot  goltime.Timestamp
}

Packet for modelling data passed to GoShare into a structure of possible fields.

func CreatePacket

func CreatePacket(packetArray []string) Packet

CreatePacket formulates Packet structure from passed message array.

func PacketFromHTTPRequest

func PacketFromHTTPRequest(dbAction string, req *http.Request) Packet

PacketFromHTTPRequest return Packet identifiable by DBTasksOnAction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL