Message¶
Usage
use Message;
or
import Message;
- enum MsgType { NORMAL, WARNING, ERROR }¶
- enum constant NORMAL¶
- enum constant WARNING¶
- enum constant ERROR¶
- record MsgTuple¶
Encapsulates the message string and message type.
- var msg : string¶
- var msgType : MsgType¶
- var msgFormat : MsgFormat¶
- var user : string¶
- var payload : bytes¶
- record RequestMsg¶
Encapsulates state corresponding to a client request sent to the Arkouda server.
- var user : string¶
- var token : string¶
- var cmd : string¶
- var format : string¶
- var args : string¶
- var size : int¶
- proc MsgTuple.init()¶
- proc MsgTuple.init(msg: string, msgType: MsgType)
- proc MsgTuple.init(msg: string, msgType: MsgType, msgFormat: MsgFormat, user = "", in payload = b"")
- proc type MsgTuple.success(msg: string = "") : MsgTuple¶
- proc type MsgTuple.newSymbol(name: string, sym: borrowed AbstractSymEntry) : MsgTuple throws¶
Create a MsgTuple indicating to the client that a new symbol was created
- proc type MsgTuple.fromResponses(responses: [] MsgTuple) : MsgTuple throws¶
Create a MsgTuple from a group of responses (useful for returning multiple symbols from one command, see: ‘unstack’ in ‘ManipulationMsg’)
If any of the responses are errors, return the first error message. Otherwise, return a success message, where each of the ‘msg’ fields are composed into a JSON list.
- proc type MsgTuple.fromScalar(scalar: ?t) : MsgTuple throws¶
- proc type MsgTuple.error(msg: string) : MsgTuple¶
- proc type MsgTuple.payload(in data: bytes) : MsgTuple
- proc ref MsgTuple.serialize(user: string) throws¶
- record ParameterObj¶
Encapsulate parameter for a request sent to the Arkouda server
Note - Only used when args is in JSON format.
Note - during the transition from space delimited string to JSON formated string, this object is not part of RequestMsg,
but will be once all messages are transitioned to JSON arguments.
- var key : string¶
- var val : string¶
- var dtype : string¶
- proc init()¶
- proc init(key: string, val: string, dtype: string)
- proc ref setKey(value: string)¶
- proc ref setVal(value: string)¶
- proc getDType()¶
Return the Dtype value as NumpyDtype
Returns Dtype
- proc getValue()¶
Return the raw string value
Returns string
- proc tryGetScalar(type t) : (t, bool)¶
- proc toScalar(type t) : t throws¶
Get a value of the given type from a JSON scalar
- Arguments:
t – type: the scalar type to parse
- Throws an ErrorWithContext if the value cannot be parsed as the given
type
- proc toScalarTuple(type t, param size: int) : size*t throws¶
Get a tuple of the given type from a JSON array of scalar values
- Arguments:
size – int: the number of elements in the tuple (must match the number of elements in the JSON array)
t – type: the scalar type to parse
- Throws an ErrorWithContext if the value is not a JSON array, the
tuple is the wrong size, or if the elements of the array cannot be parsed as the given type
- proc toScalarList(type t) : list(t) throws¶
Get a list of the given type from a JSON array of scalar values
- Arguments:
t – type: the scalar type to parse
- Throws an ErrorWithContext if the value is not a JSON array or if the
elements of the array cannot be parsed as the given type
- proc toScalarArray(type t, size: int) : [] t throws¶
Get an array of the given type from a JSON array of scalar values
- Arguments:
t – type: the scalar type to parse
size – int: the number of elements in the array (must match the number of elements in the JSON array)
- Throws an ErrorWithContext if the value is not a JSON array, the
array is the wrong size, or if the elements of the array cannot be parsed as the given type
- proc getScalarValue(type t) : t throws¶
- proc getIntValue() : int throws¶
- proc getPositiveIntValue(max: int) : int throws¶
Return the value as a positive int If the value is negative, return ‘value + max + 1’, otherwise return the value This is useful for implementing Python’s negative indexing rules
- proc getUIntValue() : uint throws¶
- proc getUInt8Value() : uint(8) throws¶
- proc getRealValue() : real throws¶
- proc getBoolValue() : bool throws¶
- proc getBigIntValue() : bigint throws¶
- proc getList(size: int) throws¶
- proc getTuple(param size: int) : size*int throws¶
- class MessageArgs : writeSerializable¶
Container class for the message arguments formatted as json :param_list: array of ParameterObj :size: int - number of parameters contained in list
- var param_list : list(ParameterObj)¶
- var size : int¶
- var payload : bytes¶
- proc init()¶
- proc init(param_list: list(ParameterObj))
- proc init(param_list: list(ParameterObj, parSafe = true), in payload: bytes)
- proc addPayload(in p: bytes)¶
Attach a binary payload to the message arguments
- proc this(key: string) : ParameterObj throws¶
Get the value of the argument with the given key
- iter these() : ParameterObj¶
- override proc serialize(writer: fileWriter(?), ref serializer: ?st) throws¶
- proc get(key: string) : ParameterObj throws¶
Identify the parameter with the provided key and return it
Returns ParameterObj with the provided key
Throws KeyNotFound error if the provide key does not exist.
- proc getValueOf(key: string) : string throws¶
- proc contains(key: string) : bool¶
Return true if there is an argument with the given name, false otherwise
- proc parseParameter(payload: string) throws¶
Parse and individual parameter components into a ParameterObj
- proc parseMessageArgs(json_str: string, size: int, in payload = b"") throws¶
Parse arguments formatted as json string into objects
- proc deserialize(ref msg: RequestMsg, request: string) throws¶
Deserializes a JSON-formatted string to a RequestMsg object, where the
JSON format is as follows (size is only set for json args. Otherwise, -1):
{“user”: “user”, “token”: “token”, “cmd”: “cmd”, “format”: “STRING”, “args”: “arg1 arg2”, “size”: “-1”}
- proc serialize(msg: string, msgType: MsgType, msgFormat: MsgFormat, user: string) : string throws¶
Generates a ReplyMsg object and serializes it into a JSON-formatted reply message