Moving from govendor to dep, updated dependencies (#48)

* Moving from govendor to dep.

* Making the pull request template more friendly.

* Fixing akward space in PR template.

* goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")`

source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
Renan DelValle 2018-01-07 13:13:47 -08:00 committed by GitHub
parent 9631aa3aab
commit 8d445c1c77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2186 changed files with 400410 additions and 352 deletions

43
vendor/git.apache.org/thrift.git/test/erl/Makefile.am generated vendored Normal file
View file

@ -0,0 +1,43 @@
#
# 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.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFT_FILES = $(wildcard ../*.thrift)
if ERLANG_OTP16
ERL_FLAG = erl:otp16
else
ERL_FLAG = erl
endif
# make sure ThriftTest.thrift is generated last to prevent conflicts with other *.thrift files
.generated: $(THRIFT_FILES)
for f in $(THRIFT_FILES) ; do \
$(THRIFT) --gen $(ERL_FLAG) -o src $$f ; \
done ; \
$(THRIFT) --gen $(ERL_FLAG) -o src ../ThriftTest.thrift
touch .generated
precross: .generated
$(REBAR) compile
clean:
rm -f .generated
rm -rf src/gen-erl
$(REBAR) clean

View file

@ -0,0 +1,6 @@
{sub_dirs, ["../../lib/erl"]}.
{erl_opts, [
debug_info,
{i, "../../lib/erl/include"}
]}.

View file

@ -0,0 +1,174 @@
%%
%% 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.
%%
-module(test_client).
-export([start/0, start/1]).
-include("gen-erl/thrift_test_types.hrl").
-record(options, {port = 9090,
client_opts = []}).
parse_args(Args) -> parse_args(Args, #options{}).
parse_args([], Opts) ->
Opts;
parse_args([Head | Rest], Opts) ->
NewOpts =
case Head of
"--port=" ++ Port ->
case string:to_integer(Port) of
{IntPort,_} when is_integer(IntPort) ->
Opts#options{port = IntPort};
_Else ->
erlang:error({bad_arg, Head})
end;
"--transport=" ++ Trans ->
% TODO: Enable Buffered and HTTP transport
case Trans of
"framed" ->
Opts#options{client_opts = [{framed, true} | Opts#options.client_opts]};
_Else ->
Opts
end;
"--ssl" ->
ssl:start(),
SslOptions =
{ssloptions, [
{certfile, "../keys/client.crt"}
,{keyfile, "../keys/server.key"}
]},
Opts#options{client_opts = [{ssltransport, true} | [SslOptions | Opts#options.client_opts]]};
"--protocol=" ++ Proto ->
Opts#options{client_opts = [{protocol, list_to_atom(Proto)}]};
_Else ->
erlang:error({bad_arg, Head})
end,
parse_args(Rest, NewOpts).
start() -> start(init:get_plain_arguments()).
start(Args) ->
#options{port = Port, client_opts = ClientOpts} = parse_args(Args),
{ok, Client0} = thrift_client_util:new(
"127.0.0.1", Port, thrift_test_thrift, ClientOpts),
DemoXtruct = #'thrift.test.Xtruct'{
string_thing = <<"Zero">>,
byte_thing = 1,
i32_thing = 9128361,
i64_thing = 9223372036854775807},
DemoNest = #'thrift.test.Xtruct2'{
byte_thing = 7,
struct_thing = DemoXtruct,
% Note that we don't set i32_thing, it will come back as undefined
% from the Python server, but 0 from the C++ server, since it is not
% optional
i32_thing = 2},
% Is it safe to match these things?
DemoDict = dict:from_list([ {Key, Key-10} || Key <- lists:seq(0,10) ]),
DemoSet = sets:from_list([ Key || Key <- lists:seq(-3,3) ]),
DemoInsane = #'thrift.test.Insanity'{
userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_FIVE, 5000}]),
xtructs = [#'thrift.test.Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
error_logger:info_msg("testVoid"),
{Client01, {ok, ok}} = thrift_client:call(Client0, testVoid, []),
error_logger:info_msg("testString"),
{Client02, {ok, <<"Test">>}} = thrift_client:call(Client01, testString, ["Test"]),
error_logger:info_msg("testString"),
{Client03, {ok, <<"Test">>}} = thrift_client:call(Client02, testString, [<<"Test">>]),
error_logger:info_msg("testByte"),
{Client04, {ok, 63}} = thrift_client:call(Client03, testByte, [63]),
error_logger:info_msg("testI32"),
{Client05, {ok, -1}} = thrift_client:call(Client04, testI32, [-1]),
error_logger:info_msg("testI32"),
{Client06, {ok, 0}} = thrift_client:call(Client05, testI32, [0]),
error_logger:info_msg("testI64"),
{Client07, {ok, -34359738368}} = thrift_client:call(Client06, testI64, [-34359738368]),
error_logger:info_msg("testDouble"),
{Client08, {ok, -5.2098523}} = thrift_client:call(Client07, testDouble, [-5.2098523]),
%% TODO: add testBinary() call
error_logger:info_msg("testStruct"),
{Client09, {ok, DemoXtruct}} = thrift_client:call(Client08, testStruct, [DemoXtruct]),
error_logger:info_msg("testNest"),
{Client10, {ok, DemoNest}} = thrift_client:call(Client09, testNest, [DemoNest]),
error_logger:info_msg("testMap"),
{Client11, {ok, DemoDict}} = thrift_client:call(Client10, testMap, [DemoDict]),
error_logger:info_msg("testSet"),
{Client12, {ok, DemoSet}} = thrift_client:call(Client11, testSet, [DemoSet]),
error_logger:info_msg("testList"),
{Client13, {ok, [-1,2,3]}} = thrift_client:call(Client12, testList, [[-1,2,3]]),
error_logger:info_msg("testEnum"),
{Client14, {ok, 1}} = thrift_client:call(Client13, testEnum, [?THRIFT_TEST_NUMBERZ_ONE]),
error_logger:info_msg("testTypedef"),
{Client15, {ok, 309858235082523}} = thrift_client:call(Client14, testTypedef, [309858235082523]),
error_logger:info_msg("testInsanity"),
{Client16, {ok, InsaneResult}} = thrift_client:call(Client15, testInsanity, [DemoInsane]),
io:format("~p~n", [InsaneResult]),
{Client17, {ok, #'thrift.test.Xtruct'{string_thing = <<"Message">>}}} =
thrift_client:call(Client16, testMultiException, ["Safe", "Message"]),
Client18 =
try
{ClientS1, Result1} = thrift_client:call(Client17, testMultiException, ["Xception", "Message"]),
io:format("Unexpected return! ~p~n", [Result1]),
ClientS1
catch
throw:{ClientS2, {exception, ExnS1 = #'thrift.test.Xception'{}}} ->
#'thrift.test.Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
ClientS2;
throw:{ClientS2, {exception, _ExnS1 = #'thrift.test.Xception2'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS2
end,
Client19 =
try
{ClientS3, Result2} = thrift_client:call(Client18, testMultiException, ["Xception2", "Message"]),
io:format("Unexpected return! ~p~n", [Result2]),
ClientS3
catch
throw:{ClientS4, {exception, _ExnS2 = #'thrift.test.Xception'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS4;
throw:{ClientS4, {exception, ExnS2 = #'thrift.test.Xception2'{}}} ->
#'thrift.test.Xception2'{errorCode = 2002,
struct_thing = #'thrift.test.Xtruct'{
string_thing = <<"This is an Xception2">>}} = ExnS2,
ClientS4
end,
%% Use deprecated erlang:now until we start requiring OTP18
%% Started = erlang:monotonic_time(milli_seconds),
{_, StartSec, StartUSec} = erlang:now(),
error_logger:info_msg("testOneway"),
{Client20, {ok, ok}} = thrift_client:call(Client19, testOneway, [1]),
{_, EndSec, EndUSec} = erlang:now(),
Elapsed = (EndSec - StartSec) * 1000 + (EndUSec - StartUSec) / 1000,
if
Elapsed > 1000 -> exit(1);
true -> true
end,
thrift_client:close(Client20).

View file

@ -0,0 +1,233 @@
%%
%% 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.
%%
-module(test_thrift_server).
-export([start/0, start/1, start_link/2, handle_function/2]).
-include("thrift_constants.hrl").
-include("gen-erl/thrift_test_types.hrl").
-record(options, {port = 9090,
server_opts = []}).
parse_args(Args) -> parse_args(Args, #options{}).
parse_args([], Opts) ->
Opts;
parse_args([Head | Rest], Opts) ->
NewOpts =
case Head of
"--port=" ++ Port ->
case string:to_integer(Port) of
{IntPort,_} when is_integer(IntPort) ->
Opts#options{port = IntPort};
_Else ->
erlang:error({bad_arg, Head})
end;
"--transport=" ++ Trans ->
case Trans of
"framed" ->
Opts#options{server_opts = [{framed, true} | Opts#options.server_opts]};
_Else ->
Opts
end;
"--ssl" ->
ssl:start(),
SslOptions =
{ssloptions, [
{certfile, "../keys/server.crt"}
,{keyfile, "../keys/server.key"}
]},
Opts#options{server_opts = [{ssltransport, true} | [SslOptions | Opts#options.server_opts]]};
"--protocol=" ++ Proto ->
Opts#options{server_opts = [{protocol, list_to_atom(Proto)} | Opts#options.server_opts]};
_Else ->
erlang:error({bad_arg, Head})
end,
parse_args(Rest, NewOpts).
start() -> start(init:get_plain_arguments()).
start(Args) ->
#options{port = Port, server_opts = ServerOpts} = parse_args(Args),
spawn(fun() -> start_link(Port, ServerOpts), receive after infinity -> ok end end).
start_link(Port, ServerOpts) ->
thrift_socket_server:start([{handler, ?MODULE},
{service, thrift_test_thrift},
{port, Port}] ++
ServerOpts).
handle_function(testVoid, {}) ->
io:format("testVoid~n"),
ok;
handle_function(testString, {S}) when is_binary(S) ->
io:format("testString: ~p~n", [S]),
{reply, S};
handle_function(testBool, {B}) when is_boolean(B) ->
io:format("testBool: ~p~n", [B]),
{reply, B};
handle_function(testByte, {I8}) when is_integer(I8) ->
io:format("testByte: ~p~n", [I8]),
{reply, I8};
handle_function(testI32, {I32}) when is_integer(I32) ->
io:format("testI32: ~p~n", [I32]),
{reply, I32};
handle_function(testI64, {I64}) when is_integer(I64) ->
io:format("testI64: ~p~n", [I64]),
{reply, I64};
handle_function(testDouble, {Double}) when is_float(Double) ->
io:format("testDouble: ~p~n", [Double]),
{reply, Double};
handle_function(testBinary, {S}) when is_binary(S) ->
io:format("testBinary: ~p~n", [S]),
{reply, S};
handle_function(testStruct,
{Struct = #'thrift.test.Xtruct'{string_thing = String,
byte_thing = Byte,
i32_thing = I32,
i64_thing = I64}})
when is_binary(String),
is_integer(Byte),
is_integer(I32),
is_integer(I64) ->
io:format("testStruct: ~p~n", [Struct]),
{reply, Struct};
handle_function(testNest,
{Nest}) when is_record(Nest, 'thrift.test.Xtruct2'),
is_record(Nest#'thrift.test.Xtruct2'.struct_thing, 'thrift.test.Xtruct') ->
io:format("testNest: ~p~n", [Nest]),
{reply, Nest};
handle_function(testMap, {Map}) ->
io:format("testMap: ~p~n", [dict:to_list(Map)]),
{reply, Map};
handle_function(testStringMap, {Map}) ->
io:format("testStringMap: ~p~n", [dict:to_list(Map)]),
{reply, Map};
handle_function(testSet, {Set}) ->
true = sets:is_set(Set),
io:format("testSet: ~p~n", [sets:to_list(Set)]),
{reply, Set};
handle_function(testList, {List}) when is_list(List) ->
io:format("testList: ~p~n", [List]),
{reply, List};
handle_function(testEnum, {Enum}) when is_integer(Enum) ->
io:format("testEnum: ~p~n", [Enum]),
{reply, Enum};
handle_function(testTypedef, {UserID}) when is_integer(UserID) ->
io:format("testTypedef: ~p~n", [UserID]),
{reply, UserID};
handle_function(testMapMap, {Hello}) ->
io:format("testMapMap: ~p~n", [Hello]),
PosList = [{I, I} || I <- lists:seq(1, 4)],
NegList = [{-I, -I} || I <- lists:seq(1, 4)],
MapMap = dict:from_list([{4, dict:from_list(PosList)},
{-4, dict:from_list(NegList)}]),
{reply, MapMap};
handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'thrift.test.Insanity') ->
Hello = #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
byte_thing = 2,
i32_thing = 2,
i64_thing = 2},
Goodbye = #'thrift.test.Xtruct'{string_thing = <<"Goodbye4">>,
byte_thing = 4,
i32_thing = 4,
i64_thing = 4},
Crazy = #'thrift.test.Insanity'{
userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
xtructs = [Goodbye]
},
Looney = #'thrift.test.Insanity'{},
FirstMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_TWO, Insanity},
{?THRIFT_TEST_NUMBERZ_THREE, Insanity}]),
SecondMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_SIX, Looney}]),
Insane = dict:from_list([{1, FirstMap},
{2, SecondMap}]),
io:format("Return = ~p~n", [Insane]),
{reply, Insane};
handle_function(testMulti, Args = {Arg0, Arg1, Arg2, _Arg3, Arg4, Arg5})
when is_integer(Arg0),
is_integer(Arg1),
is_integer(Arg2),
is_integer(Arg4),
is_integer(Arg5) ->
io:format("testMulti(~p)~n", [Args]),
{reply, #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
byte_thing = Arg0,
i32_thing = Arg1,
i64_thing = Arg2}};
handle_function(testException, {String}) when is_binary(String) ->
io:format("testException(~p)~n", [String]),
case String of
<<"Xception">> ->
throw(#'thrift.test.Xception'{errorCode = 1001,
message = String});
<<"TException">> ->
throw({?TApplicationException_Structure});
_ ->
ok
end;
handle_function(testMultiException, {Arg0, Arg1}) ->
io:format("testMultiException(~p, ~p)~n", [Arg0, Arg1]),
case Arg0 of
<<"Xception">> ->
throw(#'thrift.test.Xception'{errorCode = 1001,
message = <<"This is an Xception">>});
<<"Xception2">> ->
throw(#'thrift.test.Xception2'{errorCode = 2002,
struct_thing =
#'thrift.test.Xtruct'{string_thing = <<"This is an Xception2">>}});
_ ->
{reply, #'thrift.test.Xtruct'{string_thing = Arg1}}
end;
handle_function(testOneway, {Seconds}) ->
io:format("testOneway: ~p~n", [Seconds]),
timer:sleep(1000 * Seconds),
ok.

View file

@ -0,0 +1,54 @@
%%
%% 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.
%%
%%% -*- mode:erlang -*-
{application, thrift_test, [
% A quick description of the application.
{description, "Thrift cross language test"},
% The version of the applicaton
{vsn, "0.10.0"},
% All modules used by the application.
{modules, [
test_client,
test_thrift_server
]},
% All of the registered names the application uses. This can be ignored.
{registered, []},
% Applications that are to be started prior to this one. This can be ignored
% leave it alone unless you understand it well and let the .rel files in
% your release handle this.
{applications, [kernel, stdlib]},
% OTP application loader will load, but not start, included apps. Again
% this can be ignored as well. To load but not start an application it
% is easier to include it in the .rel file followed by the atom 'none'
{included_applications, []},
% configuration parameters similar to those in the config file specified
% on the command line. can be fetched with gas:get_env
{env, [
% If an error/crash occurs during processing of a function,
% should the TApplicationException serialized back to the client
% include the erlang backtrace?
{exceptions_include_traces, true}
]}
]}.