[ 
https://issues.apache.org/jira/browse/AVRO-1778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15357202#comment-15357202
 ] 

Matthieu Monsch commented on AVRO-1778:
---------------------------------------

Your example is somewhat hard to read because of formatting but it looks like 
you are instantiating the client properly. The problem is that you are emitting 
incorrect data (confirmed by the error message: invalid request: invalid 
["null", "string"]: "tz_ns").

As we discussed earlier, you have to use wrapped unions (since your protocol 
contains a union with multiple records - the filters - see again here for 
motivation on this: 
https://github.com/mtth/avsc/wiki/API#class-unwrappeduniontypeattrs-opts). The 
data you are emitting for each union should therefore also be wrapped (similar 
to how their JSON encoding is defined here: 
https://avro.apache.org/docs/1.8.0/spec.html#json_encoding).

More concretely, using your example for a query message, the following records 
are valid:

{code}
{
  "table": "qBeoBPxHeHsADmfB",
  "nameSpace": {
    "string": "kIlafv" // Note how this string is "wrapped".
  },
  "queryORSaveArgses": [
    {
      "rowKey": "",
      "families": []
    }
  ],
  "filterType": null
}
{code}

{code}
{
  "table": "TKbOlkvExOjCTdvKUqgjhTSnvrwM",
  "nameSpace": null, // nulls aren't wrapped (see how JSON encoding is defined)
  "queryORSaveArgses": [],
  "filterType": {
    "com.hbs.avro.dto.FilterType": { // Likewise, this value is wrapped.
      "rowFilterType": {
        "com.hbs.avro.dto.FirstKeyOnlyFilter": {
          "firstKeyOnlyFilter": false
        }
      },
      "familyFilterType": {
        "com.hbs.avro.dto.FamilyFilter": {
          "byteArrayComparable": "RegexStringComparator",
          "compareOp": "LESS_OR_EQUAL"
        }
      },
      "columnFilterType": {
        "com.hbs.avro.dto.ColumnRangeFilter": {
          "minColumn": "bBkcoCJvCkNiSWq",
          "minColumnInclusive": false,
          "maxColumn": "wvOW",
          "maxColumnInclusive": false
        }
      },
      "columnValueFilterType": null,
      "pageFilterType": null
    }
  }
}
{code}

If you pass either of these records to your emit call, the request should go 
through. Hopefully this makes sense; if you have any further questions, please 
open a new ticket rather than overload this one.

> IPC/RPC for JavaScript
> ----------------------
>
>                 Key: AVRO-1778
>                 URL: https://issues.apache.org/jira/browse/AVRO-1778
>             Project: Avro
>          Issue Type: Improvement
>          Components: javascript
>            Reporter: Matthieu Monsch
>            Assignee: Ryan Blue
>         Attachments: AVRO-1778.patch
>
>
> This patch adds protocols to the JavaScript implementation.
> The API was designed to:
> + Be simple and idiomatic. The `Protocol` class added here is heavily 
> inspired by node.js' core `EventEmitter` to keep things as familiar as 
> possible [1]. Getting a client and server working is straightforward and 
> requires very few lines of code [2].
> + Support arbitrary transports, both stateful and stateless. Built-in node.js 
> streams are supported out of the box (e.g. TCP/UNIX sockets, or even 
> stdin/stdout). Exchanging messages over a custom transport requires 
> implementing a single simple function (see [3] for an example).
> + Work both server-side and in the browser!
> Ps: I also tested against both the Java and Python implementations over HTTP 
> and communication worked. 
> [1] https://github.com/mtth/avsc/wiki/API#ipc--rpc
> [2] https://github.com/mtth/avsc/wiki/Advanced-usage#remote-procedure-calls
> [3] https://github.com/mtth/avsc/wiki/Advanced-usage#transient-streams



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to