Example #1
0
func (gc *GearmanClient) AddServer(host string, port int) int {
	var ret C.gearman_return_t

	ret = C.gearman_client_add_server(gc.clientp, C.CString(host), C.in_port_t(port))

	fmt.Println("ret:", ret, int(ret) == GEARMAN_SUCCESS)
	return int(ret)
	// return GEARMAN_SUCCESS;
}
Example #2
0
func Atest() {
	var i int
	i = 1
	fmt.Println("go int: %v, %v", i, C.GEARMAN_ERROR)

	var gmret C.gearman_return_t = C.GEARMAN_SUCCESS
	var gmch C.gearman_client_st
	var gmchp *C.gearman_client_st = nil
	var gmtask *C.gearman_task_st = nil
	var gmarg C.gearman_argument_t
	var gmres *C.gearman_result_st = nil
	var gmbret C._Bool
	var cvoid unsafe.Pointer

	fmt.Println("cvoid*:", cvoid)

	gmchp, err := C.gearman_client_create(&gmch)

	fmt.Println("abcd:", err, "------", gmchp, (gmchp == &gmch), gmret)

	gmret, err = C.gearman_client_add_server(gmchp, C.CString("10.207.16.251"), 1235)

	gmtask, err = C.gearman_execute(gmchp, C.CString("gmworker_node_10.207.15.65_dummy"),
		C.strlen(C.CString("gmworker_node_10.207.15.65_dummy")), nil, 0, nil, &gmarg, nil)

	gmbret, err = C.gearman_success(uint32(C.gearman_task_return(gmtask)))

	fmt.Println("succ: ", gmbret, err)

	gmres, err = C.gearman_task_result(gmtask)

	fmt.Println("res:", C.GoStringN(C.gearman_result_value(gmres),
		C.int(C.gearman_result_size(gmres))))

	C.gearman_client_free(gmchp)
}