+var RMRErrors = map[int]string{
+ C.RMR_OK: "state is good",
+ C.RMR_ERR_BADARG: "argument passed to function was unusable",
+ C.RMR_ERR_NOENDPT: "send/call could not find an endpoint based on msg type",
+ C.RMR_ERR_EMPTY: "msg received had no payload; attempt to send an empty message",
+ C.RMR_ERR_NOHDR: "message didn't contain a valid header",
+ C.RMR_ERR_SENDFAILED: "send failed; errno has nano reason",
+ C.RMR_ERR_CALLFAILED: "unable to send call() message",
+ C.RMR_ERR_NOWHOPEN: "no wormholes are open",
+ C.RMR_ERR_WHID: "wormhole id was invalid",
+ C.RMR_ERR_OVERFLOW: "operation would have busted through a buffer/field size",
+ C.RMR_ERR_RETRY: "request (send/call/rts) failed, but caller should retry (EAGAIN for wrappers)",
+ C.RMR_ERR_RCVFAILED: "receive failed (hard error)",
+ C.RMR_ERR_TIMEOUT: "message processing call timed out",
+ C.RMR_ERR_UNSET: "the message hasn't been populated with a transport buffer",
+ C.RMR_ERR_TRUNC: "received message likely truncated",
+ C.RMR_ERR_INITFAILED: "initialization of something (probably message) failed",
+ C.RMR_ERR_NOTSUPP: "the request is not supported, or RMr was not initialized for the request",
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+type RMRParams struct {
+ Mtype int
+ Payload []byte
+ PayloadLen int
+ Meid *RMRMeid
+ Xid string
+ SubId int
+ Src string
+ Mbuf *C.rmr_mbuf_t
+ Whid int
+ Callid int
+ Timeout int
+ status int
+}
+
+func (params *RMRParams) String() string {
+ var b bytes.Buffer
+ fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s Paylens=%d/%d Paymd5=%x)", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid, params.PayloadLen, len(params.Payload), md5.Sum(params.Payload))
+ return b.String()
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+type RMRClientParams struct {
+ StatDesc string
+ RmrData PortData
+}
+
+func (params *RMRClientParams) String() string {
+ return fmt.Sprintf("ProtPort=%d MaxSize=%d ThreadType=%d StatDesc=%s LowLatency=%t FastAck=%t Policies=%v",
+ params.RmrData.Port, params.RmrData.MaxSize, params.RmrData.ThreadType, params.StatDesc,
+ params.RmrData.LowLatency, params.RmrData.FastAck, params.RmrData.Policies)
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+func NewRMRClientWithParams(params *RMRClientParams) *RMRClient {
+ p := C.CString(fmt.Sprintf("%d", params.RmrData.Port))
+ m := C.int(params.RmrData.MaxSize)
+ c := C.int(params.RmrData.ThreadType)
+ defer C.free(unsafe.Pointer(p))
+ ctx := C.rmr_init(p, m, c)