Ejemplo n.º 1
0
func TestRequestorZeromq() {
	_packet := goshare.Packet{}
	_packet.KeyType = "default"

	_packet.DBAction = "push"
	_packet.HashMap = make(golhashmap.HashMap)
	_packet.HashMap["an0n"] = "ymous"
	strPacket := string(goshare_requestor.RequestPacketBytes(&_packet))
	result, err = golzmq.ZmqRequest(zmqSock, strPacket)
	expected = ""
	golassert.AssertEqual(result, expected)
	golassert.AssertEqual(err, nil)

	_packet.DBAction = "read"
	_packet.KeyList = []string{"an0n"}
	strPacket = string(goshare_requestor.RequestPacketBytes(&_packet))
	result, err = golzmq.ZmqRequest(zmqSock, strPacket)
	expected = "an0n,ymous"
	golassert.AssertEqual(result, expected)
	golassert.AssertEqual(err, nil)

	_packet.DBAction = "delete"
	strPacket = string(goshare_requestor.RequestPacketBytes(&_packet))
	result, err = golzmq.ZmqRequest(zmqSock, strPacket)
	expected = ""
	golassert.AssertEqual(result, expected)
	golassert.AssertEqual(err, nil)

	_packet.DBAction = "read"
	strPacket = string(goshare_requestor.RequestPacketBytes(&_packet))
	result, err = golzmq.ZmqRequest(zmqSock, strPacket)
	expected = "Error for request sent: read default-default an0n"
	golassert.AssertEqual(result, expected)
	golassert.AssertEqual(err, nil)
}
Ejemplo n.º 2
0
/* formulate Task-Type from other info in Packet */
func taskTypeFromPacket(packet *goshare.Packet) (task_type string) {
	if packet.ValType == "" {
		packet.ValType = "default"
	}

	task_type = fmt.Sprintf("%s-%s", packet.KeyType, packet.ValType)

	if packet.ParentNS != "" {
		task_type = fmt.Sprintf("%s-parentNS", task_type)
	}
	return task_type
}