]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/nodejs/examples/client_multitransport.js
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / nodejs / examples / client_multitransport.js
CommitLineData
f67539c2
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19var thrift = require('thrift'),
20 ttransport = require('thrift/transport');
21
22var UserStorage = require('./gen-nodejs/UserStorage'),
23 ttypes = require('./gen-nodejs/user_types');
24
25var f_conn = thrift.createConnection('localhost', 9090), // default: framed
26 f_client = thrift.createClient(UserStorage, f_conn);
27var b_conn = thrift.createConnection('localhost', 9091, {transport: ttransport.TBufferedTransport}),
28 b_client = thrift.createClient(UserStorage, b_conn);
29var user1 = new ttypes.UserProfile({uid: 1,
30 name: "Mark Slee",
31 blurb: "I'll find something to put here."});
32var user2 = new ttypes.UserProfile({uid: 2,
33 name: "Satoshi Tagomori",
34 blurb: "ok, let's test with buffered transport."});
35
36f_conn.on('error', function(err) {
37 console.error("framed:", err);
38});
39
40f_client.store(user1, function(err, response) {
41 if (err) { console.error(err); return; }
42
43 console.log("stored:", user1.uid, " as ", user1.name);
44 b_client.retrieve(user1.uid, function(err, responseUser) {
45 if (err) { console.error(err); return; }
46 console.log("retrieved:", responseUser.uid, " as ", responseUser.name);
47 });
48});
49
50b_client.store(user2, function(err, response) {
51 if (err) { console.error(err); return; }
52
53 console.log("stored:", user2.uid, " as ", user2.name);
54 f_client.retrieve(user2.uid, function(err, responseUser) {
55 if (err) { console.error(err); return; }
56 console.log("retrieved:", responseUser.uid, " as ", responseUser.name);
57 });
58});