uber-node / tcurl

A command line utility to talk to tchannel servers
MIT License
36 stars 7 forks source link

Untangle #53

Closed kriskowal closed 9 years ago

kriskowal commented 9 years ago

These are a few initial steps toward untangling the control flow, complexity, and bad UX that has accumulated in TCurl.

kriskowal commented 9 years ago

r @ShanniLi @Raynos @jcorbin

Please give this a spin to assess the usability. Example:

before❯ node index.js -p 127.0.0.1:21300 -t ~/larry/thrift/stooges.thrift larry Stooges::nyuck
'Got call response ok'
{ name: 'larry', language: 'python' }

after❯ node index.js -p 127.0.0.1:21300 -t ~/larry/thrift/stooges.thrift larry Stooges::nyuck | jq
{
  "ok": true,
  "head": {},
  "body": {
    "name": "larry",
    "language": "python"
  },
  "headers": {
    "as": "thrift"
  }
}

❯ node index.js -p 127.0.0.1:21300 autobahn connections_v1 -3 '{"serviceName": "larry"}' | jq
{
  "ok": true,
  "head": null,
  "body": {
    "127.0.0.1:21300": {
      "instances": {
        "10.32.193.49:56903": {
          "connected": {
            "in": true,
            "out": true
          },
          "identified": {
            "in": true,
            "out": true
          },
          "serviceNames": [
            "larry"
          ]
        }
      }
    },
    "127.0.0.1:21301": {
      "instances": {
        "10.32.193.49:56903": {
          "connected": {
            "in": true,
            "out": true
          },
          "identified": {
            "in": true,
            "out": true
          },
          "serviceNames": [
            "larry"
          ]
        }
      }
    }
  },
  "headers": {
    "as": "json"
  }
}
Raynos commented 9 years ago

@kriskowal

Can you show an example of "error frame", "not ok response" and "ECONNREFUSED" with this new tcurl ?

kriskowal commented 9 years ago

@Raynos, stderr as follows, exit code 1.

{ [TchannelBadRequestError: Endpoint 'Meta::health' is not defined]
  type: 'tchannel.bad-request',
  message: 'Endpoint \'Meta::health\' is not defined',
  isErrorFrame: true,
  codeName: 'BadRequest',
  errorCode: 6,
  originalId: 2,
  name: 'TchannelBadRequestError',
  fullType: 'tchannel.bad-request' }

I believe from our offline discussion you would like this to be stdout. I think it would be good to surface the "errorCode" as the exit code, so 6.

{
    "isErrorFrame": true,
    "message": "Endpoint \'Meta::health\' is not defined",
    "codeName": "BadRequest",
    "errorCode": 6,
    "originalId": 2,
    "name": "TchannelBadRequestError",
    "fullType": "tchannel.bad-request"
}
kriskowal commented 9 years ago

Feedback fed back. Please yay or nay.

jcorbin commented 9 years ago

:8ball: says :ship:

ShanniLi commented 9 years ago

Would appreciate answering the question about assert.ifError v.s. if (err) { assert.end(err) }

Other than that, lgtm.

kriskowal commented 9 years ago

Yeah, thought I had. assert.ifError is non-fatal and does not stop the test, just as delegate.error is non-fatal and does not indicate that tcurl is finished. That is the sole purview of delegate.exit. Thanks for your feedback!

ShanniLi commented 9 years ago

Make sense. Thanks! @kriskowal