Skip to content
Browse files

thrift npm package

  • Loading branch information...
0 parents commit e5f6e3e3b883a9293a780bf0026aaf2d0de35400 @Jae Jae committed
Showing with 5,543 additions and 0 deletions.
  1. +13 −0 node_modules/thrift/LICENSE
  2. +5 −0 node_modules/thrift/NOTICE
  3. +50 −0 node_modules/thrift/README.md
  4. +45 −0 node_modules/thrift/example.coffee
  5. +30 −0 node_modules/thrift/example.js
  6. +15 −0 node_modules/thrift/examples/README.md
  7. +489 −0 node_modules/thrift/examples/cassandra.thrift
  8. +31 −0 node_modules/thrift/examples/client.js
  9. +247 −0 node_modules/thrift/examples/gen-js/UserStorage.js
  10. +79 −0 node_modules/thrift/examples/gen-js/user_types.js
  11. +464 −0 node_modules/thrift/examples/gen-nodejs/JobExchange.js
  12. +295 −0 node_modules/thrift/examples/gen-nodejs/UserStorage.js
  13. +143 −0 node_modules/thrift/examples/gen-nodejs/scheduler_types.js
  14. +80 −0 node_modules/thrift/examples/gen-nodejs/user_types.js
  15. 0 node_modules/thrift/examples/gen-py.twisted/__init__.py
  16. +99 −0 node_modules/thrift/examples/gen-py.twisted/scheduler/JobExchange-remote
  17. +561 −0 node_modules/thrift/examples/gen-py.twisted/scheduler/JobExchange.py
  18. +1 −0 node_modules/thrift/examples/gen-py.twisted/scheduler/__init__.py
  19. +9 −0 node_modules/thrift/examples/gen-py.twisted/scheduler/constants.py
  20. +147 −0 node_modules/thrift/examples/gen-py.twisted/scheduler/ttypes.py
  21. +92 −0 node_modules/thrift/examples/gen-py.twisted/user/UserStorage-remote
  22. +386 −0 node_modules/thrift/examples/gen-py.twisted/user/UserStorage.py
  23. +1 −0 node_modules/thrift/examples/gen-py.twisted/user/__init__.py
  24. +9 −0 node_modules/thrift/examples/gen-py.twisted/user/constants.py
  25. +99 −0 node_modules/thrift/examples/gen-py.twisted/user/ttypes.py
  26. +17 −0 node_modules/thrift/examples/scheduler.thrift
  27. +21 −0 node_modules/thrift/examples/server.js
  28. +10 −0 node_modules/thrift/examples/user.thrift
  29. +24 −0 node_modules/thrift/httptimeout.js
  30. +11 −0 node_modules/thrift/jobclient.js
  31. +21 −0 node_modules/thrift/jobserver.js
  32. +261 −0 node_modules/thrift/lib/thrift/binary_parser.js
  33. +144 −0 node_modules/thrift/lib/thrift/connection.js
  34. +8 −0 node_modules/thrift/lib/thrift/index.js
  35. +368 −0 node_modules/thrift/lib/thrift/pack.js
  36. +319 −0 node_modules/thrift/lib/thrift/protocol.js
  37. +33 −0 node_modules/thrift/lib/thrift/server.js
  38. +120 −0 node_modules/thrift/lib/thrift/thrift.js
  39. +57 −0 node_modules/thrift/lib/thrift/transport.js
  40. +9 −0 node_modules/thrift/package.json
  41. +18 −0 node_modules/thrift/scheduler/client.js
  42. +464 −0 node_modules/thrift/scheduler/gen-nodejs/JobExchange.js
  43. +136 −0 node_modules/thrift/scheduler/gen-nodejs/scheduler_types.js
  44. +19 −0 node_modules/thrift/scheduler/scheduler.thrift
  45. +28 −0 node_modules/thrift/scheduler/server.js
  46. +29 −0 node_modules/thrift/t/example.js
  47. +19 −0 node_modules/thrift/test.js
  48. +17 −0 node_modules/thrift/timeout.js
13 node_modules/thrift/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2010-2011 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
5 node_modules/thrift/NOTICE
@@ -0,0 +1,5 @@
+Thrift Node.js JavaScript Library
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
50 node_modules/thrift/README.md
@@ -0,0 +1,50 @@
+# node-thrift
+
+Thrift protocol implementation for nodejs. As of version 0.0.1, the basic
+protocol has been implemented. A Thrift compiler that will generate the .js
+files from a Thrift specification is being implemented as well, see the
+Thrift Compiler section below.
+
+NOTE: you must use the framed thrift transport, TFramedTransport in most
+implementations, on the server side. Using a popular example, this is enabled
+by default in Cassandra 0.7 (but configuration must be changed in Cassandra
+0.6.x and earlier).
+
+## Install
+
+ npm install thrift
+
+## Thrift Compiler
+
+A Thrift compiler is included in the 0.6.0 release of Thrift. You can
+compile nodejs sources by running the following:
+
+ thrift --gen js:node thrift_file
+
+## Cassandra Client Example:
+
+Here is a Cassandra example:
+
+ var thrift = require('thrift'),
+ Cassandra = require('./gen-nodejs/Cassandra')
+ ttypes = require('./gen-nodejs/cassandra_types');
+
+ var connection = thrift.createConnection("localhost", 9160),
+ client = thrift.createClient(Cassandra, connection);
+
+ connection.on('error', function(err) {
+ console.error(err);
+ });
+
+ client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF"}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', finish: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
+ if (err) {
+ // handle err
+ } else {
+ // data == [ttypes.ColumnOrSuperColumn, ...]
+ }
+ connection.end();
+ });
+
+## Custom client and server example
+
+An example based on the one shown on the Thrift front page is included in the [examples](https://github.com/wadey/node-thrift/tree/master/examples) folder.
45 node_modules/thrift/example.coffee
@@ -0,0 +1,45 @@
+thrift = require './lib'
+Cassandra = require './examples/Cassandra'
+ttypes = require './examples/cassandra_types'
+
+connection = thrift.createConnection("localhost", 9162)
+client = thrift.createClient(Cassandra.Client, connection)
+
+connection.on 'error', (err) ->
+ console.error(err)
+
+client.get_slice "Users", "js2", new ttypes.ColumnParent(column_family: "User"), new ttypes.SlicePredicate(slice_range: new ttypes.SliceRange(start: '', finish: '')), ttypes.ConsistencyLevel.ONE, (err, data) ->
+ console.log ['get_slice'], err, data
+#
+#
+#client.get "Users", "js2", new ttypes.ColumnPath(column_family: "User", column: "username"), ttypes.ConsistencyLevel.ONE, (err, data) ->
+# console.log(['get'], err, data)
+#
+##client.insert "Users", "js2", new ttypes.ColumnPath(column_family: "User", column: "username"), "value", Date.now(), ttypes.ConsistencyLevel.ONE
+#
+#
+client.describe_version (err, data) ->
+ console.log(['v'], err, data)
+
+client.describe_keyspaces (err, data) ->
+ console.log(['dk'], err, data)
+
+client.batch_mutate "Users",
+ {"js2": {
+ "User": [
+ new ttypes.Mutation(column_or_supercolumn:
+ new ttypes.ColumnOrSuperColumn(column: new ttypes.Column(name: "usernane", value: "blah", timestamp: Date.now()))
+ )
+ ]
+ }},
+ ttypes.ConsistencyLevel.ONE,
+ () ->
+
+#
+#//client.get_slice("Users", "1", new ColumnParent({column_family: "User", super_column: null}), new SlicePredicate({slice_range: new SliceRange({start: '', end: ''})}), ConsistencyLevel.ONE, function(err, data) {
+#// console.log(err, data);
+#//});
+#
+#//client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF", super_column: null}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', end: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
+#// console.log(err, data);
+#//});
30 node_modules/thrift/example.js
@@ -0,0 +1,30 @@
+var thrift = require('./lib'),
+ Cassandra = require('./examples/Cassandra')
+ ttypes = require('./examples/cassandra_types');
+
+var connection = thrift.createConnection("localhost", 9162);
+var client = thrift.createClient(Cassandra.Client, connection);
+
+connection.on('error', function(err) {
+ console.error(err);
+});
+
+client.get_slice("Users", "js2", new ttypes.ColumnParent({column_family: "User"}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', finish: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
+ console.log(['get_slice'], err, data);
+});
+
+client.get("Users", "js2", new ttypes.ColumnPath({column_family: "User", column: "username"}), ttypes.ConsistencyLevel.ONE, function(err, data) {
+ console.log(['get'], err, data);
+});
+
+client.insert("Users", "js2", new ttypes.ColumnPath({column_family: "User", column: "username"}), "value", Date.now(), ttypes.ConsistencyLevel.ONE);
+
+client.batch_mutate("Users", {"js": {"User": [new ttypes.Mutation({column_or_supercolumn: new ttypes.ColumnOrSuperColumn({column: new ttypes.Column({name: "usernane", value: "blah", timestamp: Date.now()})})})]}}, ttypes.ConsistencyLevel.ONE);
+
+//client.get_slice("Users", "1", new ColumnParent({column_family: "User", super_column: null}), new SlicePredicate({slice_range: new SliceRange({start: '', end: ''})}), ConsistencyLevel.ONE, function(err, data) {
+// console.log(err, data);
+//});
+
+//client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF", super_column: null}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', end: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
+// console.log(err, data);
+//});
15 node_modules/thrift/examples/README.md
@@ -0,0 +1,15 @@
+# Running the user example
+
+To run the user example, first start up the server in one terminal:
+
+ node server.js
+
+Now run the client:
+
+ node client.js
+
+# Regenerating the bindings
+
+If you want to regenerated the bindings, you can run:
+
+ thrift --gen js:node user.thrift
489 node_modules/thrift/examples/cassandra.thrift
@@ -0,0 +1,489 @@
+#!/usr/local/bin/thrift --java --php --py
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# *** PLEASE REMEMBER TO EDIT THE VERSION CONSTANT WHEN MAKING CHANGES ***
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#
+# Interface definition for Cassandra Service
+#
+
+namespace java org.apache.cassandra.thrift
+namespace cpp org.apache.cassandra
+namespace csharp Apache.Cassandra
+namespace py cassandra
+namespace php cassandra
+namespace perl Cassandra
+
+# Thrift.rb has a bug where top-level modules that include modules
+# with the same name are not properly referenced, so we can't do
+# Cassandra::Cassandra::Client.
+namespace rb CassandraThrift
+
+# The API version (NOT the product version), composed as a dot delimited
+# string with major, minor, and patch level components.
+#
+# - Major: Incremented for backward incompatible changes. An example would
+# be changes to the number or disposition of method arguments.
+# - Minor: Incremented for backward compatible changes. An example would
+# be the addition of a new (optional) method.
+# - Patch: Incremented for bug fixes. The patch level should be increased
+# for every edit that doesn't result in a change to major/minor.
+#
+# See the Semantic Versioning Specification (SemVer) http://semver.org.
+const string VERSION = "2.1.0"
+
+#
+# data structures
+#
+
+/** Basic unit of data within a ColumnFamily.
+ * @param name. A column name can act both as structure (a label) or as data (like value). Regardless, the name of the column
+ * is used as a key to its value.
+ * @param value. Some data
+ * @param timestamp. Used to record when data was sent to be written.
+ */
+struct Column {
+ 1: required binary name,
+ 2: required binary value,
+ 3: required i64 timestamp,
+}
+
+/** A named list of columns.
+ * @param name. see Column.name.
+ * @param columns. A collection of standard Columns. The columns within a super column are defined in an adhoc manner.
+ * Columns within a super column do not have to have matching structures (similarly named child columns).
+ */
+struct SuperColumn {
+ 1: required binary name,
+ 2: required list<Column> columns,
+}
+
+/**
+ Methods for fetching rows/records from Cassandra will return either a single instance of ColumnOrSuperColumn or a list
+ of ColumnOrSuperColumns (get_slice()). If you're looking up a SuperColumn (or list of SuperColumns) then the resulting
+ instances of ColumnOrSuperColumn will have the requested SuperColumn in the attribute super_column. For queries resulting
+ in Columns, those values will be in the attribute column. This change was made between 0.3 and 0.4 to standardize on
+ single query methods that may return either a SuperColumn or Column.
+
+ @param column. The Column returned by get() or get_slice().
+ @param super_column. The SuperColumn returned by get() or get_slice().
+ */
+struct ColumnOrSuperColumn {
+ 1: optional Column column,
+ 2: optional SuperColumn super_column,
+}
+
+
+#
+# Exceptions
+# (note that internal server errors will raise a TApplicationException, courtesy of Thrift)
+#
+
+/** A specific column was requested that does not exist. */
+exception NotFoundException {
+}
+
+/** Invalid request could mean keyspace or column family does not exist, required parameters are missing, or a parameter is malformed.
+ why contains an associated error message.
+*/
+exception InvalidRequestException {
+ 1: required string why
+}
+
+/** Not all the replicas required could be created and/or read. */
+exception UnavailableException {
+}
+
+/** RPC timeout was exceeded. either a node failed mid-operation, or load was too high, or the requested op was too large. */
+exception TimedOutException {
+}
+
+/** invalid authentication request (user does not exist or credentials invalid) */
+exception AuthenticationException {
+ 1: required string why
+}
+
+/** invalid authorization request (user does not have access to keyspace) */
+exception AuthorizationException {
+ 1: required string why
+}
+
+
+#
+# service api
+#
+/** The ConsistencyLevel is an enum that controls both read and write behavior based on <ReplicationFactor> in your
+ * storage-conf.xml. The different consistency levels have different meanings, depending on if you're doing a write or read
+ * operation. Note that if W + R > ReplicationFactor, where W is the number of nodes to block for on write, and R
+ * the number to block for on reads, you will have strongly consistent behavior; that is, readers will always see the most
+ * recent write. Of these, the most interesting is to do QUORUM reads and writes, which gives you consistency while still
+ * allowing availability in the face of node failures up to half of <ReplicationFactor>. Of course if latency is more
+ * important than consistency then you can use lower values for either or both.
+ *
+ * Write:
+ * ZERO Ensure nothing. A write happens asynchronously in background
+ * ANY Ensure that the write has been written once somewhere, including possibly being hinted in a non-target node.
+ * ONE Ensure that the write has been written to at least 1 node's commit log and memory table before responding to the client.
+ * QUORUM Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes before responding to the client.
+ * ALL Ensure that the write is written to <code>&lt;ReplicationFactor&gt;</code> nodes before responding to the client.
+ *
+ * Read:
+ * ZERO Not supported, because it doesn't make sense.
+ * ANY Not supported. You probably want ONE instead.
+ * ONE Will return the record returned by the first node to respond. A consistency check is always done in a
+ * background thread to fix any consistency issues when ConsistencyLevel.ONE is used. This means subsequent
+ * calls will have correct data even if the initial read gets an older value. (This is called 'read repair'.)
+ * QUORUM Will query all storage nodes and return the record with the most recent timestamp once it has at least a
+ * majority of replicas reported. Again, the remaining replicas will be checked in the background.
+ * ALL Not yet supported, but we plan to eventually.
+*/
+enum ConsistencyLevel {
+ ZERO = 0,
+ ONE = 1,
+ QUORUM = 2,
+ DCQUORUM = 3,
+ DCQUORUMSYNC = 4,
+ ALL = 5,
+ ANY = 6,
+}
+
+/**
+ ColumnParent is used when selecting groups of columns from the same ColumnFamily. In directory structure terms, imagine
+ ColumnParent as ColumnPath + '/../'.
+
+ See also <a href="cassandra.html#Struct_ColumnPath">ColumnPath</a>
+ */
+struct ColumnParent {
+ 3: required string column_family,
+ 4: optional binary super_column,
+}
+
+/** The ColumnPath is the path to a single column in Cassandra. It might make sense to think of ColumnPath and
+ * ColumnParent in terms of a directory structure.
+ *
+ * ColumnPath is used to looking up a single column.
+ *
+ * @param column_family. The name of the CF of the column being looked up.
+ * @param super_column. The super column name.
+ * @param column. The column name.
+ */
+struct ColumnPath {
+ 3: required string column_family,
+ 4: optional binary super_column,
+ 5: optional binary column,
+}
+
+/**
+ A slice range is a structure that stores basic range, ordering and limit information for a query that will return
+ multiple columns. It could be thought of as Cassandra's version of LIMIT and ORDER BY
+
+ @param start. The column name to start the slice with. This attribute is not required, though there is no default value,
+ and can be safely set to '', i.e., an empty byte array, to start with the first column name. Otherwise, it
+ must a valid value under the rules of the Comparator defined for the given ColumnFamily.
+ @param finish. The column name to stop the slice at. This attribute is not required, though there is no default value,
+ and can be safely set to an empty byte array to not stop until 'count' results are seen. Otherwise, it
+ must also be a value value to the ColumnFamily Comparator.
+ @param reversed. Whether the results should be ordered in reversed order. Similar to ORDER BY blah DESC in SQL.
+ @param count. How many keys to return. Similar to LIMIT 100 in SQL. May be arbitrarily large, but Thrift will
+ materialize the whole result into memory before returning it to the client, so be aware that you may
+ be better served by iterating through slices by passing the last value of one call in as the 'start'
+ of the next instead of increasing 'count' arbitrarily large.
+ */
+struct SliceRange {
+ 1: required binary start,
+ 2: required binary finish,
+ 3: required bool reversed=0,
+ 4: required i32 count=100,
+}
+
+/**
+ A SlicePredicate is similar to a mathematic predicate (see http://en.wikipedia.org/wiki/Predicate_(mathematical_logic)),
+ which is described as "a property that the elements of a set have in common."
+
+ SlicePredicate's in Cassandra are described with either a list of column_names or a SliceRange. If column_names is
+ specified, slice_range is ignored.
+
+ @param column_name. A list of column names to retrieve. This can be used similar to Memcached's "multi-get" feature
+ to fetch N known column names. For instance, if you know you wish to fetch columns 'Joe', 'Jack',
+ and 'Jim' you can pass those column names as a list to fetch all three at once.
+ @param slice_range. A SliceRange describing how to range, order, and/or limit the slice.
+ @param ignore.
+ */
+struct SlicePredicate {
+ 1: optional list<binary> column_names,
+ 2: optional SliceRange slice_range,
+ 3: optional bool ignore=0,
+}
+
+/**
+The semantics of start keys and tokens are slightly different.
+Keys are start-inclusive; tokens are start-exclusive. Token
+ranges may also wrap -- that is, the end token may be less
+than the start one. Thus, a range from keyX to keyX is a
+one-element range, but a range from tokenY to tokenY is the
+full ring.
+*/
+struct KeyRange {
+ 1: optional string start_key,
+ 2: optional string end_key,
+ 3: optional string start_token,
+ 4: optional string end_token,
+ 5: required i32 count=100
+}
+
+/**
+ A KeySlice is key followed by the data it maps to. A collection of KeySlice is returned by the get_range_slice operation.
+
+ @param key. a row key
+ @param columns. List of data represented by the key. Typically, the list is pared down to only the columns specified by
+ a SlicePredicate.
+ */
+struct KeySlice {
+ 1: required string key,
+ 2: required list<ColumnOrSuperColumn> columns,
+}
+
+struct Deletion {
+ 1: required i64 timestamp,
+ 2: optional binary super_column,
+ 3: optional SlicePredicate predicate,
+}
+
+/**
+ A Mutation is either an insert, represented by filling column_or_supercolumn, or a deletion, represented by filling the deletion attribute.
+ @param column_or_supercolumn. An insert to a column or supercolumn
+ @param deletion. A deletion of a column or supercolumn
+*/
+struct Mutation {
+ 1: optional ColumnOrSuperColumn column_or_supercolumn,
+ 2: optional Deletion deletion,
+}
+
+struct TokenRange {
+ 1: required string start_token,
+ 2: required string end_token,
+ 3: required list<string> endpoints,
+}
+
+/**
+ Authentication requests can contain any data, dependent on the AuthenticationBackend used
+*/
+struct AuthenticationRequest {
+ 1: required map<string, string> credentials,
+}
+
+
+service Cassandra {
+ # auth methods
+ void login(1: required string keyspace, 2:required AuthenticationRequest auth_request) throws (1:AuthenticationException authnx, 2:AuthorizationException authzx),
+
+ # retrieval methods
+
+ /**
+ Get the Column or SuperColumn at the given column_path. If no value is present, NotFoundException is thrown. (This is
+ the only method that can throw an exception under non-failure conditions.)
+ */
+ ColumnOrSuperColumn get(1:required string keyspace,
+ 2:required string key,
+ 3:required ColumnPath column_path,
+ 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:NotFoundException nfe, 3:UnavailableException ue, 4:TimedOutException te),
+
+ /**
+ Get the group of columns contained by column_parent (either a ColumnFamily name or a ColumnFamily/SuperColumn name
+ pair) specified by the given SlicePredicate. If no matching values are found, an empty list is returned.
+ */
+ list<ColumnOrSuperColumn> get_slice(1:required string keyspace,
+ 2:required string key,
+ 3:required ColumnParent column_parent,
+ 4:required SlicePredicate predicate,
+ 5:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ Perform a get for column_path in parallel on the given list<string> keys. The return value maps keys to the
+ ColumnOrSuperColumn found. If no value corresponding to a key is present, the key will still be in the map, but both
+ the column and super_column references of the ColumnOrSuperColumn object it maps to will be null.
+ @deprecated; use multiget_slice
+ */
+ map<string,ColumnOrSuperColumn> multiget(1:required string keyspace,
+ 2:required list<string> keys,
+ 3:required ColumnPath column_path,
+ 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ Performs a get_slice for column_parent and predicate for the given keys in parallel.
+ */
+ map<string,list<ColumnOrSuperColumn>> multiget_slice(1:required string keyspace,
+ 2:required list<string> keys,
+ 3:required ColumnParent column_parent,
+ 4:required SlicePredicate predicate,
+ 5:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ returns the number of columns for a particular <code>key</code> and <code>ColumnFamily</code> or <code>SuperColumn</code>.
+ */
+ i32 get_count(1:required string keyspace,
+ 2:required string key,
+ 3:required ColumnParent column_parent,
+ 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ returns a subset of columns for a range of keys.
+ @Deprecated. Use get_range_slices instead
+ */
+ list<KeySlice> get_range_slice(1:required string keyspace,
+ 2:required ColumnParent column_parent,
+ 3:required SlicePredicate predicate,
+ 4:required string start_key="",
+ 5:required string finish_key="",
+ 6:required i32 row_count=100,
+ 7:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ returns a subset of columns for a range of keys.
+ */
+ list<KeySlice> get_range_slices(1:required string keyspace,
+ 2:required ColumnParent column_parent,
+ 3:required SlicePredicate predicate,
+ 4:required KeyRange range,
+ 5:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ # modification methods
+
+ /**
+ Insert a Column consisting of (column_path.column, value, timestamp) at the given column_path.column_family and optional
+ column_path.super_column. Note that column_path.column is here required, since a SuperColumn cannot directly contain binary
+ values -- it can only contain sub-Columns.
+ */
+ void insert(1:required string keyspace,
+ 2:required string key,
+ 3:required ColumnPath column_path,
+ 4:required binary value,
+ 5:required i64 timestamp,
+ 6:required ConsistencyLevel consistency_level=ConsistencyLevel.ZERO)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ Insert Columns or SuperColumns across different Column Families for the same row key. batch_mutation is a
+ map<string, list<ColumnOrSuperColumn>> -- a map which pairs column family names with the relevant ColumnOrSuperColumn
+ objects to insert.
+ @deprecated; use batch_mutate instead
+ */
+ void batch_insert(1:required string keyspace,
+ 2:required string key,
+ 3:required map<string, list<ColumnOrSuperColumn>> cfmap,
+ 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ZERO)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ /**
+ Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note
+ that all the values in column_path besides column_path.column_family are truly optional: you can remove the entire
+ row by just specifying the ColumnFamily, or you can remove a SuperColumn or a single Column by specifying those levels too.
+ */
+ void remove(1:required string keyspace,
+ 2:required string key,
+ 3:required ColumnPath column_path,
+ 4:required i64 timestamp,
+ 5:ConsistencyLevel consistency_level=ConsistencyLevel.ZERO)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ void batch_mutate(1:required string keyspace,
+ 2:required map<string, map<string, list<Mutation>>> mutation_map,
+ 3:required ConsistencyLevel consistency_level=ConsistencyLevel.ZERO)
+ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
+
+ // Meta-APIs -- APIs to get information about the node or cluster,
+ // rather than user data. The nodeprobe program provides usage examples.
+
+ /** get property whose value is of type string. @Deprecated */
+ string get_string_property(1:required string property),
+
+ /** get property whose value is list of strings. @Deprecated */
+ list<string> get_string_list_property(1:required string property),
+
+ /** list the defined keyspaces in this cluster */
+ set<string> describe_keyspaces(),
+
+ /** get the cluster name */
+ string describe_cluster_name(),
+
+ /** get the thrift api version */
+ string describe_version(),
+
+ /** get the token ring: a map of ranges to host addresses,
+ represented as a set of TokenRange instead of a map from range
+ to list of endpoints, because you can't use Thrift structs as
+ map keys:
+ https://issues.apache.org/jira/browse/THRIFT-162
+
+ for the same reason, we can't return a set here, even though
+ order is neither important nor predictable. */
+ list<TokenRange> describe_ring(1:required string keyspace),
+
+ /** describe specified keyspace */
+ map<string, map<string, string>> describe_keyspace(1:required string keyspace)
+ throws (1:NotFoundException nfe),
+
+ # Added by SimpleGeo.
+
+ # take a snapshot of a node
+ void take_snapshot(1:required string table_name
+ 2:required string snapshot_name),
+
+ # force table cleanup for all keyspaces
+ void force_table_clean(),
+
+ # force table compaction for all keyspaces
+ void force_table_compaction(),
+
+ # force table flush
+ void force_table_flush(1:required string table_name),
+
+ # retrieve stats for a table
+ #
+ # Each table defines multiple column families. The map that is returned defines
+ # stats about each column family, including an 'overall' key which combines all column
+ # family stats.
+ #
+ # Every value in the returned map (except the value that is mapped from 'overall') contains the following keys:
+ # read_count, memtable_columns_count, memtable_data_size, memtable_switch_count,
+ # column_family, read_latency, write_count, write_latency, pending_tasks
+ #
+ # The 'overall' key maps to a value that only has: read_count, read_latency, write_count, write_latency and pending_tasks.
+ #
+ # Both '0' or 'NaN' can be used as values for all keys.
+ map<string, map<string,string>> get_table_stats(1:required string table_name) throws (1: NotFoundException nfe),
+
+
+ /** experimental API for hadoop/parallel query support.
+ may change violently and without warning.
+
+ returns list of token strings such that first subrange is (list[0], list[1]],
+ next is (list[1], list[2]], etc. */
+ list<string> describe_splits(1:required string start_token,
+ 2:required string end_token,
+ 3:required i32 keys_per_split),
+}
+
31 node_modules/thrift/examples/client.js
@@ -0,0 +1,31 @@
+var thrift = require('thrift');
+
+var UserStorage = require('./gen-nodejs/UserStorage.js'),
+ ttypes = require('./gen-nodejs/user_types');
+
+var connection = thrift.createConnection('localhost', 9090),
+ client = thrift.createClient(UserStorage, connection);
+
+var user = new ttypes.UserProfile({uid: 1,
+ name: "Mark Slee",
+ blurb: "I'll find something to put here."});
+
+connection.on('error', function(err) {
+ console.error(err);
+});
+
+client.store(user, function(err, response) {
+ if (err) {
+ console.error(err);
+ } else {
+ console.log("stored:", user.uid);
+ client.retrieve(user.uid, function(err, responseUser) {
+ if (err) {
+ console.error(err);
+ } else {
+ console.log("retrieved:", responseUser.uid);
+ connection.end();
+ }
+ });
+ }
+});
247 node_modules/thrift/examples/gen-js/UserStorage.js
@@ -0,0 +1,247 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+
+//HELPER FUNCTIONS AND STRUCTURES
+
+UserStorage_store_args = function(args){
+ this.user = null
+if( args != null ){ if (null != args.user)
+ this.user = args.user
+}}
+UserStorage_store_args.prototype = {}
+UserStorage_store_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.STRUCT) {
+ this.user = new UserProfile()
+ this.user.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_store_args.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_store_args')
+ if (null != this.user) {
+ output.writeFieldBegin('user', Thrift.Type.STRUCT, 1)
+ this.user.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+UserStorage_store_result = function(args){
+}
+UserStorage_store_result.prototype = {}
+UserStorage_store_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_store_result.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_store_result')
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+UserStorage_retrieve_args = function(args){
+ this.uid = null
+if( args != null ){ if (null != args.uid)
+ this.uid = args.uid
+}}
+UserStorage_retrieve_args.prototype = {}
+UserStorage_retrieve_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ this.uid = input.readI32().value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_retrieve_args.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_retrieve_args')
+ if (null != this.uid) {
+ output.writeFieldBegin('uid', Thrift.Type.I32, 1)
+ output.writeI32(this.uid)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+UserStorage_retrieve_result = function(args){
+ this.success = null
+if( args != null ){ if (null != args.success)
+ this.success = args.success
+}}
+UserStorage_retrieve_result.prototype = {}
+UserStorage_retrieve_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 0: if (ftype == Thrift.Type.STRUCT) {
+ this.success = new UserProfile()
+ this.success.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_retrieve_result.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_retrieve_result')
+ if (null != this.success) {
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0)
+ this.success.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+UserStorageClient = function(input, output) {
+ this.input = input
+ this.output = null == output ? input : output
+ this.seqid = 0
+}
+UserStorageClient.prototype = {}
+UserStorageClient.prototype.store = function(user){
+ this.send_store(user)
+ this.recv_store()
+}
+
+UserStorageClient.prototype.send_store = function(user){
+ this.output.writeMessageBegin('store', Thrift.MessageType.CALL, this.seqid)
+ var args = new UserStorage_store_args()
+ args.user = user
+ args.write(this.output)
+ this.output.writeMessageEnd()
+ return this.output.getTransport().flush()
+}
+
+UserStorageClient.prototype.recv_store = function(){
+ var ret = this.input.readMessageBegin()
+ var fname = ret.fname
+ var mtype = ret.mtype
+ var rseqid= ret.rseqid
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(this.input)
+ this.input.readMessageEnd()
+ throw x
+ }
+ var result = new UserStorage_store_result()
+ result.read(this.input)
+ this.input.readMessageEnd()
+
+ return
+}
+UserStorageClient.prototype.retrieve = function(uid){
+ this.send_retrieve(uid)
+ return this.recv_retrieve()
+}
+
+UserStorageClient.prototype.send_retrieve = function(uid){
+ this.output.writeMessageBegin('retrieve', Thrift.MessageType.CALL, this.seqid)
+ var args = new UserStorage_retrieve_args()
+ args.uid = uid
+ args.write(this.output)
+ this.output.writeMessageEnd()
+ return this.output.getTransport().flush()
+}
+
+UserStorageClient.prototype.recv_retrieve = function(){
+ var ret = this.input.readMessageBegin()
+ var fname = ret.fname
+ var mtype = ret.mtype
+ var rseqid= ret.rseqid
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(this.input)
+ this.input.readMessageEnd()
+ throw x
+ }
+ var result = new UserStorage_retrieve_result()
+ result.read(this.input)
+ this.input.readMessageEnd()
+
+ if (null != result.success ) {
+ return result.success
+ }
+ throw "retrieve failed: unknown result"
+}
79 node_modules/thrift/examples/gen-js/user_types.js
@@ -0,0 +1,79 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+
+UserProfile = function(args){
+ this.uid = null
+ this.name = null
+ this.blurb = null
+if( args != null ){ if (null != args.uid)
+ this.uid = args.uid
+ if (null != args.name)
+ this.name = args.name
+ if (null != args.blurb)
+ this.blurb = args.blurb
+}}
+UserProfile.prototype = {}
+UserProfile.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ this.uid = input.readI32().value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 2: if (ftype == Thrift.Type.STRING) {
+ this.name = input.readString().value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 3: if (ftype == Thrift.Type.STRING) {
+ this.blurb = input.readString().value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserProfile.prototype.write = function(output){
+ output.writeStructBegin('UserProfile')
+ if (null != this.uid) {
+ output.writeFieldBegin('uid', Thrift.Type.I32, 1)
+ output.writeI32(this.uid)
+ output.writeFieldEnd()
+ }
+ if (null != this.name) {
+ output.writeFieldBegin('name', Thrift.Type.STRING, 2)
+ output.writeString(this.name)
+ output.writeFieldEnd()
+ }
+ if (null != this.blurb) {
+ output.writeFieldBegin('blurb', Thrift.Type.STRING, 3)
+ output.writeString(this.blurb)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
464 node_modules/thrift/examples/gen-nodejs/JobExchange.js
@@ -0,0 +1,464 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+var Thrift = require('thrift').Thrift;
+var ttypes = require('./scheduler_types.js');
+//HELPER FUNCTIONS AND STRUCTURES
+
+var JobExchange_insert_job_args = function(args){
+ this.j = null
+if( args != null ){ if (null != args.j)
+ this.j = args.j
+}}
+JobExchange_insert_job_args.prototype = {}
+JobExchange_insert_job_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.STRUCT) {
+ this.j = new ttypes.Job()
+ this.j.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_insert_job_args.prototype.write = function(output){
+ output.writeStructBegin('JobExchange_insert_job_args')
+ if (null != this.j) {
+ output.writeFieldBegin('j', Thrift.Type.STRUCT, 1)
+ this.j.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchange_insert_job_result = function(args){
+ this.success = null
+if( args != null ){ if (null != args.success)
+ this.success = args.success
+}}
+JobExchange_insert_job_result.prototype = {}
+JobExchange_insert_job_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 0: if (ftype == Thrift.Type.I32) {
+ var rtmp = input.readI32()
+this.success = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_insert_job_result.prototype.write = function(output){
+ output.writeStructBegin('JobExchange_insert_job_result')
+ if (null != this.success) {
+ output.writeFieldBegin('success', Thrift.Type.I32, 0)
+ output.writeI32(this.success)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchange_get_job_args = function(args){
+ this.jid = null
+if( args != null ){ if (null != args.jid)
+ this.jid = args.jid
+}}
+JobExchange_get_job_args.prototype = {}
+JobExchange_get_job_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ var rtmp = input.readI32()
+this.jid = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_get_job_args.prototype.write = function(output){
+ output.writeStructBegin('JobExchange_get_job_args')
+ if (null != this.jid) {
+ output.writeFieldBegin('jid', Thrift.Type.I32, 1)
+ output.writeI32(this.jid)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchange_get_job_result = function(args){
+ this.success = null
+if( args != null ){ if (null != args.success)
+ this.success = args.success
+}}
+JobExchange_get_job_result.prototype = {}
+JobExchange_get_job_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 0: if (ftype == Thrift.Type.STRUCT) {
+ this.success = new ttypes.Job()
+ this.success.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_get_job_result.prototype.write = function(output){
+ output.writeStructBegin('JobExchange_get_job_result')
+ if (null != this.success) {
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0)
+ this.success.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchange_get_all_args = function(args){
+}
+JobExchange_get_all_args.prototype = {}
+JobExchange_get_all_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_get_all_args.prototype.write = function(output){
+ output.writeStructBegin('JobExchange_get_all_args')
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchange_get_all_result = function(args){
+ this.success = null
+if( args != null ){ if (null != args.success)
+ this.success = args.success
+}}
+JobExchange_get_all_result.prototype = {}
+JobExchange_get_all_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 0: if (ftype == Thrift.Type.SET) {
+ {
+ var _size0 = 0
+ var rtmp3
+ this.success = []
+ var _etype3 = 0
+ rtmp3 = input.readSetBegin()
+ _etype3= rtmp3.etype
+ _size0 = rtmp3.size
+ console.log(rtmp3);
+ for (var _i4 = 0; _i4 < _size0; ++_i4)
+ {
+ var elem5 = null
+ elem5 = new ttypes.Job()
+ elem5.read(input)
+ this.success.push(elem5)
+ }
+ input.readSetEnd()
+ }
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+JobExchange_get_all_result.prototype.write = function(output){
+ console.log(['get_all_result'], this.success.length);
+ output.writeStructBegin('JobExchange_get_all_result')
+ if (null != this.success) {
+ output.writeFieldBegin('success', Thrift.Type.SET, 0)
+ output.writeSetBegin(Thrift.Type.STRUCT, this.success.length)
+ console.log('output.writeSetBegin', Thrift.Type.STRUCT, this.success.length);
+ {
+ for(var iter6 in this.success)
+ {
+ iter6=this.success[iter6]
+ iter6.write(output)
+ }
+ }
+ output.writeSetEnd()
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var JobExchangeClient = exports.Client = function(output, pClass) {
+ this.output = output;
+ this.pClass = pClass;
+ this.seqid = 0;
+ this._reqs = {}
+}
+JobExchangeClient.prototype = {}
+JobExchangeClient.prototype.insert_job = function(j,callback){
+ this.seqid += 1;
+ this._reqs[this.seqid] = callback;
+ this.send_insert_job(j)
+}
+
+JobExchangeClient.prototype.send_insert_job = function(j){
+ var output = new this.pClass(this.output);
+ output.writeMessageBegin('insert_job', Thrift.MessageType.CALL, this.seqid)
+ var args = new JobExchange_insert_job_args()
+ args.j = j
+ args.write(output)
+ output.writeMessageEnd()
+ return this.output.flush()
+}
+
+JobExchangeClient.prototype.recv_insert_job = function(input,mtype,rseqid){
+ var callback = this._reqs[rseqid] || function() {};
+ delete this._reqs[rseqid];
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(input)
+ input.readMessageEnd()
+ return callback(x);
+ }
+ var result = new JobExchange_insert_job_result()
+ result.read(input)
+ input.readMessageEnd()
+
+ if (null != result.success ) {
+ return callback(null, result.success);
+ }
+ return callback("insert_job failed: unknown result");
+}
+JobExchangeClient.prototype.get_job = function(jid,callback){
+ this.seqid += 1;
+ this._reqs[this.seqid] = callback;
+ this.send_get_job(jid)
+}
+
+JobExchangeClient.prototype.send_get_job = function(jid){
+ var output = new this.pClass(this.output);
+ output.writeMessageBegin('get_job', Thrift.MessageType.CALL, this.seqid)
+ var args = new JobExchange_get_job_args()
+ args.jid = jid
+ args.write(output)
+ output.writeMessageEnd()
+ return this.output.flush()
+}
+
+JobExchangeClient.prototype.recv_get_job = function(input,mtype,rseqid){
+ var callback = this._reqs[rseqid] || function() {};
+ delete this._reqs[rseqid];
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(input)
+ input.readMessageEnd()
+ return callback(x);
+ }
+ var result = new JobExchange_get_job_result()
+ result.read(input)
+ input.readMessageEnd()
+
+ if (null != result.success ) {
+ return callback(null, result.success);
+ }
+ return callback("get_job failed: unknown result");
+}
+JobExchangeClient.prototype.get_all = function(callback){
+ this.seqid += 1;
+ this._reqs[this.seqid] = callback;
+ this.send_get_all()
+}
+
+JobExchangeClient.prototype.send_get_all = function(){
+ var output = new this.pClass(this.output);
+ output.writeMessageBegin('get_all', Thrift.MessageType.CALL, this.seqid)
+ var args = new JobExchange_get_all_args()
+ args.write(output)
+ output.writeMessageEnd()
+ return this.output.flush()
+}
+
+JobExchangeClient.prototype.recv_get_all = function(input,mtype,rseqid){
+ var callback = this._reqs[rseqid] || function() {};
+ delete this._reqs[rseqid];
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(input)
+ input.readMessageEnd()
+ return callback(x);
+ }
+ var result = new JobExchange_get_all_result()
+ result.read(input)
+ input.readMessageEnd()
+
+ if (null != result.success ) {
+ return callback(null, result.success);
+ }
+ return callback("get_all failed: unknown result");
+}
+var JobExchangeProcessor = exports.Processor = function(handler) {
+ this._handler = handler
+}
+JobExchangeProcessor.prototype.process = function(input, output) {
+ var r = input.readMessageBegin()
+ if (this['process_' + r.fname]) {
+ return this['process_' + r.fname].call(this, r.rseqid, input, output)
+ } else {
+ input.skip(Thrift.Type.STRUCT)
+ input.readMessageEnd()
+ var x = new Thrift.TApplicationException(Thrift.TApplicationException.Type.UNKNOWN_METHOD, 'Unknown function ' + r.fname)
+ output.writeMessageBegin(r.fname, Thrift.MessageType.Exception, r.rseqid)
+ x.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ }
+}
+
+JobExchangeProcessor.prototype.process_insert_job = function(seqid, input, output) {
+ var args = new JobExchange_insert_job_args()
+ args.read(input)
+ input.readMessageEnd()
+ var result = new JobExchange_insert_job_result()
+ this._handler.insert_job(args.j, function(success) {
+ result.success = success
+ output.writeMessageBegin("insert_job", Thrift.MessageType.REPLY, seqid)
+ result.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ })
+}
+
+JobExchangeProcessor.prototype.process_get_job = function(seqid, input, output) {
+ var args = new JobExchange_get_job_args()
+ args.read(input)
+ input.readMessageEnd()
+ var result = new JobExchange_get_job_result()
+ this._handler.get_job(args.jid, function(success) {
+ result.success = success
+ output.writeMessageBegin("get_job", Thrift.MessageType.REPLY, seqid)
+ result.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ })
+}
+
+JobExchangeProcessor.prototype.process_get_all = function(seqid, input, output) {
+ var args = new JobExchange_get_all_args()
+ args.read(input)
+ input.readMessageEnd()
+ var result = new JobExchange_get_all_result()
+ this._handler.get_all(function(success) {
+ result.success = success
+ output.writeMessageBegin("get_all", Thrift.MessageType.REPLY, seqid)
+ result.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ })
+}
+
295 node_modules/thrift/examples/gen-nodejs/UserStorage.js
@@ -0,0 +1,295 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+var Thrift = require('thrift').Thrift;
+var ttypes = require('./user_types.js');
+//HELPER FUNCTIONS AND STRUCTURES
+
+var UserStorage_store_args = function(args){
+ this.user = null
+if( args != null ){ if (null != args.user)
+ this.user = args.user
+}}
+UserStorage_store_args.prototype = {}
+UserStorage_store_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.STRUCT) {
+ this.user = new ttypes.UserProfile()
+ this.user.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_store_args.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_store_args')
+ if (null != this.user) {
+ output.writeFieldBegin('user', Thrift.Type.STRUCT, 1)
+ this.user.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var UserStorage_store_result = function(args){
+}
+UserStorage_store_result.prototype = {}
+UserStorage_store_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_store_result.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_store_result')
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var UserStorage_retrieve_args = function(args){
+ this.uid = null
+if( args != null ){ if (null != args.uid)
+ this.uid = args.uid
+}}
+UserStorage_retrieve_args.prototype = {}
+UserStorage_retrieve_args.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ this.uid = input.readI32()
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_retrieve_args.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_retrieve_args')
+ if (null != this.uid) {
+ output.writeFieldBegin('uid', Thrift.Type.I32, 1)
+ output.writeI32(this.uid)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var UserStorage_retrieve_result = function(args){
+ this.success = null
+if( args != null ){ if (null != args.success)
+ this.success = args.success
+}}
+UserStorage_retrieve_result.prototype = {}
+UserStorage_retrieve_result.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 0: if (ftype == Thrift.Type.STRUCT) {
+ this.success = new ttypes.UserProfile()
+ this.success.read(input)
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserStorage_retrieve_result.prototype.write = function(output){
+ output.writeStructBegin('UserStorage_retrieve_result')
+ if (null != this.success) {
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0)
+ this.success.write(output)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
+var UserStorageClient = exports.Client = function(output, pClass) {
+ this.output = output;
+ this.pClass = pClass;
+ this.seqid = 0;
+ this._reqs = {}
+}
+UserStorageClient.prototype = {}
+UserStorageClient.prototype.store = function(user,callback){
+ this.seqid += 1;
+ this._reqs[this.seqid] = callback;
+ this.send_store(user)
+}
+
+UserStorageClient.prototype.send_store = function(user){
+ var output = new this.pClass(this.output);
+ output.writeMessageBegin('store', Thrift.MessageType.CALL, this.seqid)
+ var args = new UserStorage_store_args()
+ args.user = user
+ args.write(output)
+ output.writeMessageEnd()
+ return this.output.flush()
+}
+
+UserStorageClient.prototype.recv_store = function(input,mtype,rseqid){
+ var callback = this._reqs[rseqid] || function() {};
+ delete this._reqs[rseqid];
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(input)
+ input.readMessageEnd()
+ return callback(x);
+ }
+ var result = new UserStorage_store_result()
+ result.read(input)
+ input.readMessageEnd()
+
+ callback(null)
+}
+UserStorageClient.prototype.retrieve = function(uid,callback){
+ this.seqid += 1;
+ this._reqs[this.seqid] = callback;
+ this.send_retrieve(uid)
+}
+
+UserStorageClient.prototype.send_retrieve = function(uid){
+ var output = new this.pClass(this.output);
+ output.writeMessageBegin('retrieve', Thrift.MessageType.CALL, this.seqid)
+ var args = new UserStorage_retrieve_args()
+ args.uid = uid
+ args.write(output)
+ output.writeMessageEnd()
+ return this.output.flush()
+}
+
+UserStorageClient.prototype.recv_retrieve = function(input,mtype,rseqid){
+ var callback = this._reqs[rseqid] || function() {};
+ delete this._reqs[rseqid];
+ if (mtype == Thrift.MessageType.EXCEPTION) {
+ var x = new Thrift.ApplicationException()
+ x.read(input)
+ input.readMessageEnd()
+ return callback(x);
+ }
+ var result = new UserStorage_retrieve_result()
+ result.read(input)
+ input.readMessageEnd()
+
+ if (null != result.success ) {
+ return callback(null, result.success);
+ }
+ return callback("retrieve failed: unknown result");
+}
+var UserStorageProcessor = exports.Processor = function(handler) {
+ this._handler = handler
+}
+UserStorageProcessor.prototype.process = function(input, output) {
+ var r = input.readMessageBegin()
+ if (this['process_' + r.fname]) {
+ return this['process_' + r.fname].call(this, r.rseqid, input, output)
+ } else {
+ input.skip(Thrift.Type.STRUCT)
+ input.readMessageEnd()
+ var x = new Thrift.TApplicationException(Thrift.TApplicationException.Type.UNKNOWN_METHOD, 'Unknown function ' + r.fname)
+ output.writeMessageBegin(r.fname, Thrift.MessageType.Exception, r.rseqid)
+ x.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ }
+}
+
+UserStorageProcessor.prototype.process_store = function(seqid, input, output) {
+ var args = new UserStorage_store_args()
+ args.read(input)
+ input.readMessageEnd()
+ var result = new UserStorage_store_result()
+ this._handler.store(args.user, function(success) {
+ result.success = success
+ output.writeMessageBegin("store", Thrift.MessageType.REPLY, seqid)
+ result.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ })
+}
+
+UserStorageProcessor.prototype.process_retrieve = function(seqid, input, output) {
+ var args = new UserStorage_retrieve_args()
+ args.read(input)
+ input.readMessageEnd()
+ var result = new UserStorage_retrieve_result()
+ this._handler.retrieve(args.uid, function(success) {
+ result.success = success
+ output.writeMessageBegin("retrieve", Thrift.MessageType.REPLY, seqid)
+ result.write(output)
+ output.writeMessageEnd()
+ output.flush()
+ })
+}
+
143 node_modules/thrift/examples/gen-nodejs/scheduler_types.js
@@ -0,0 +1,143 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+var Thrift = require('thrift').Thrift;
+var ttypes = module.exports = {};
+var Job = module.exports.Job = function(args){
+ this.id = null
+ this.type = null
+ this.increment = null
+ this.params = null
+ this.period = null
+ this.last_run = null
+ this.next_run = null
+if( args != null ){ if (null != args.id)
+ this.id = args.id
+ if (null != args.type)
+ this.type = args.type
+ if (null != args.increment)
+ this.increment = args.increment
+ if (null != args.params)
+ this.params = args.params
+ if (null != args.period)
+ this.period = args.period
+ if (null != args.last_run)
+ this.last_run = args.last_run
+ if (null != args.next_run)
+ this.next_run = args.next_run
+}}
+Job.prototype = {}
+Job.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ var rtmp = input.readI32()
+this.id = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 2: if (ftype == Thrift.Type.STRING) {
+ var rtmp = input.readString()
+this.type = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 3: if (ftype == Thrift.Type.I32) {
+ var rtmp = input.readI32()
+this.increment = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 4: if (ftype == Thrift.Type.STRING) {
+ var rtmp = input.readString()
+this.params = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 5: if (ftype == Thrift.Type.STRING) {
+ var rtmp = input.readString()
+this.period = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 6: if (ftype == Thrift.Type.STRING) {
+ var rtmp = input.readString()
+this.last_run = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 7: if (ftype == Thrift.Type.STRING) {
+ var rtmp = input.readString()
+this.next_run = rtmp.value
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+Job.prototype.write = function(output){
+ output.writeStructBegin('Job')
+ if (null != this.id) {
+ output.writeFieldBegin('id', Thrift.Type.I32, 1)
+ output.writeI32(this.id)
+ output.writeFieldEnd()
+ }
+ if (null != this.type) {
+ output.writeFieldBegin('type', Thrift.Type.STRING, 2)
+ output.writeString(this.type)
+ output.writeFieldEnd()
+ }
+ if (null != this.increment) {
+ output.writeFieldBegin('increment', Thrift.Type.I32, 3)
+ output.writeI32(this.increment)
+ output.writeFieldEnd()
+ }
+ if (null != this.params) {
+ output.writeFieldBegin('params', Thrift.Type.STRING, 4)
+ output.writeString(this.params)
+ output.writeFieldEnd()
+ }
+ if (null != this.period) {
+ output.writeFieldBegin('period', Thrift.Type.STRING, 5)
+ output.writeString(this.period)
+ output.writeFieldEnd()
+ }
+ if (null != this.last_run) {
+ output.writeFieldBegin('last_run', Thrift.Type.STRING, 6)
+ output.writeString(this.last_run)
+ output.writeFieldEnd()
+ }
+ if (null != this.next_run) {
+ output.writeFieldBegin('next_run', Thrift.Type.STRING, 7)
+ output.writeString(this.next_run)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
80 node_modules/thrift/examples/gen-nodejs/user_types.js
@@ -0,0 +1,80 @@
+//
+// Autogenerated by Thrift
+//
+// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+//
+var Thrift = require('thrift').Thrift;
+var ttypes = module.exports = {};
+var UserProfile = module.exports.UserProfile = function(args){
+ this.uid = null
+ this.name = null
+ this.blurb = null
+if( args != null ){ if (null != args.uid)
+ this.uid = args.uid
+ if (null != args.name)
+ this.name = args.name
+ if (null != args.blurb)
+ this.blurb = args.blurb
+}}
+UserProfile.prototype = {}
+UserProfile.prototype.read = function(input){
+ var ret = input.readStructBegin()
+ while (1)
+ {
+ var ret = input.readFieldBegin()
+ var fname = ret.fname
+ var ftype = ret.ftype
+ var fid = ret.fid
+ if (ftype == Thrift.Type.STOP)
+ break
+ switch(fid)
+ {
+ case 1: if (ftype == Thrift.Type.I32) {
+ this.uid = input.readI32()
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 2: if (ftype == Thrift.Type.STRING) {
+ this.name = input.readString()
+ } else {
+ input.skip(ftype)
+ }
+ break
+ case 3: if (ftype == Thrift.Type.STRING) {
+ this.blurb = input.readString()
+ } else {
+ input.skip(ftype)
+ }
+ break
+ default:
+ input.skip(ftype)
+ }
+ input.readFieldEnd()
+ }
+ input.readStructEnd()
+ return
+}
+
+UserProfile.prototype.write = function(output){
+ output.writeStructBegin('UserProfile')
+ if (null != this.uid) {
+ output.writeFieldBegin('uid', Thrift.Type.I32, 1)
+ output.writeI32(this.uid)
+ output.writeFieldEnd()
+ }
+ if (null != this.name) {
+ output.writeFieldBegin('name', Thrift.Type.STRING, 2)
+ output.writeString(this.name)
+ output.writeFieldEnd()
+ }
+ if (null != this.blurb) {
+ output.writeFieldBegin('blurb', Thrift.Type.STRING, 3)
+ output.writeString(this.blurb)
+ output.writeFieldEnd()
+ }
+ output.writeFieldStop()
+ output.writeStructEnd()
+ return
+}
+
0 node_modules/thrift/examples/gen-py.twisted/__init__.py
No changes.
99 node_modules/thrift/examples/gen-py.twisted/scheduler/JobExchange-remote
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+import JobExchange
+from ttypes import *
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+ print ''
+ print 'Usage: ' + sys.argv[0] + ' [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+ print ''
+ print 'Functions:'
+ print ' i32 insert_job(Job j)'
+ print ' Job get_job(i32 jid)'
+ print ' get_all()'
+ print ''
+ sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+ parts = sys.argv[argi+1].split(':')
+ host = parts[0]
+ port = int(parts[1])
+ argi += 2
+
+if sys.argv[argi] == '-u':
+ url = urlparse(sys.argv[argi+1])
+ parts = url[1].split(':')
+ host = parts[0]
+ if len(parts) > 1:
+ port = int(parts[1])
+ else:
+ port = 80
+ uri = url[2]
+ if url[4]:
+ uri += '?%s' % url[4]
+ http = True
+ argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+ framed = True
+ argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+ transport = THttpClient.THttpClient(host, port, uri)
+else:
+ socket = TSocket.TSocket(host, port)
+ if framed:
+ transport = TTransport.TFramedTransport(socket)
+ else:
+ transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = JobExchange.Client(protocol)
+transport.open()
+
+if cmd == 'insert_job':
+ if len(args) != 1:
+ print 'insert_job requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.insert_job(eval(args[0]),))
+
+elif cmd == 'get_job':
+ if len(args) != 1:
+ print 'get_job requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.get_job(eval(args[0]),))
+
+elif cmd == 'get_all':
+ if len(args) != 0:
+ print 'get_all requires 0 args'
+ sys.exit(1)
+ pp.pprint(client.get_all())
+
+else:
+ print 'Unrecognized method %s' % cmd
+ sys.exit(1)
+
+transport.close()
561 node_modules/thrift/examples/gen-py.twisted/scheduler/JobExchange.py
@@ -0,0 +1,561 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+from ttypes import *
+from thrift.Thrift import TProcessor
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+from zope.interface import Interface, implements
+from twisted.internet import defer
+from thrift.transport import TTwisted
+
+class Iface(Interface):
+ def insert_job(j):
+ """
+ Parameters:
+ - j
+ """
+ pass
+
+ def get_job(jid):
+ """
+ Parameters:
+ - jid
+ """
+ pass
+
+ def get_all():
+ pass
+
+
+class Client:
+ implements(Iface)
+
+ def __init__(self, transport, oprot_factory):
+ self._transport = transport
+ self._oprot_factory = oprot_factory
+ self._seqid = 0
+ self._reqs = {}
+
+ def insert_job(self, j):
+ """
+ Parameters:
+ - j
+ """
+ self._seqid += 1
+ d = self._reqs[self._seqid] = defer.Deferred()
+ self.send_insert_job(j)
+ return d
+
+ def send_insert_job(self, j):
+ oprot = self._oprot_factory.getProtocol(self._transport)
+ oprot.writeMessageBegin('insert_job', TMessageType.CALL, self._seqid)
+ args = insert_job_args()
+ args.j = j
+ args.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+
+ def recv_insert_job(self, iprot, mtype, rseqid):
+ d = self._reqs.pop(rseqid)
+ if mtype == TMessageType.EXCEPTION:
+ x = TApplicationException()
+ x.read(iprot)
+ iprot.readMessageEnd()
+ return d.errback(x)
+ result = insert_job_result()
+ result.read(iprot)
+ iprot.readMessageEnd()
+ if result.success != None:
+ return d.callback(result.success)
+ return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, "insert_job failed: unknown result"))
+
+ def get_job(self, jid):
+ """
+ Parameters:
+ - jid
+ """
+ self._seqid += 1
+ d = self._reqs[self._seqid] = defer.Deferred()
+ self.send_get_job(jid)
+ return d
+
+ def send_get_job(self, jid):
+ oprot = self._oprot_factory.getProtocol(self._transport)
+ oprot.writeMessageBegin('get_job', TMessageType.CALL, self._seqid)
+ args = get_job_args()
+ args.jid = jid
+ args.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+
+ def recv_get_job(self, iprot, mtype, rseqid):
+ d = self._reqs.pop(rseqid)
+ if mtype == TMessageType.EXCEPTION:
+ x = TApplicationException()
+ x.read(iprot)
+ iprot.readMessageEnd()
+ return d.errback(x)
+ result = get_job_result()
+ result.read(iprot)
+ iprot.readMessageEnd()
+ if result.success != None:
+ return d.callback(result.success)
+ return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, "get_job failed: unknown result"))
+
+ def get_all(self, ):
+ self._seqid += 1
+ d = self._reqs[self._seqid] = defer.Deferred()
+ self.send_get_all()
+ return d
+
+ def send_get_all(self, ):
+ oprot = self._oprot_factory.getProtocol(self._transport)
+ oprot.writeMessageBegin('get_all', TMessageType.CALL, self._seqid)
+ args = get_all_args()
+ args.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+
+ def recv_get_all(self, iprot, mtype, rseqid):
+ d = self._reqs.pop(rseqid)
+ if mtype == TMessageType.EXCEPTION:
+ x = TApplicationException()
+ x.read(iprot)
+ iprot.readMessageEnd()
+ return d.errback(x)
+ result = get_all_result()
+ result.read(iprot)
+ iprot.readMessageEnd()