public static void main()

in tchannel-example/src/main/java/com/uber/tchannel/hyperbahn/HyperbahnExample.java [48:84]


    public static void main(String[] args) throws Exception {
        TChannel tchannel = new TChannel.Builder("javaServer")
                .setServerHost(InetAddress.getByName(null))
                .setServerPort(8888)
                .build();

        tchannel.listen();

        List<InetSocketAddress> routers = Arrays.asList(
            new InetSocketAddress("127.0.0.1", 21300)
        );
        HyperbahnClient hyperbahn = new HyperbahnClient.Builder(tchannel.getServiceName(), tchannel)
                .setRouters(routers)
                .build();

        // register the service handler
        hyperbahn.makeClientChannel("javaServer")
            .registerHealthHandler()
            .register("ping", new PingRequestHandler());

        final TFuture<JsonResponse<AdvertiseResponse>> future = hyperbahn.advertise();
        future.addCallback(new TFutureCallback<JsonResponse<AdvertiseResponse>>() {
            @Override
            public void onResponse(JsonResponse<AdvertiseResponse> response) {
                if (!response.isError()) {
                    System.out.println("Got response. All set: " + response.getBody(AdvertiseResponse.class));
                } else {
                    System.out.println("Error happened: " + response.getError().getMessage());
                }
            }
        });

        Thread.sleep(TimeUnit.MILLISECONDS.convert(600, TimeUnit.SECONDS));

        tchannel.shutdown();
        hyperbahn.shutdown();
    }