Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:18
erlang-orca
orca-0.1.11-doc.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File orca-0.1.11-doc.patch of Package erlang-orca
diff -Ndurp orca-0.1.11/src/orca_conn.erl orca-0.1.11-doc/src/orca_conn.erl --- orca-0.1.11/src/orca_conn.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_conn.erl 2017-05-21 17:13:55.028165979 +0300 @@ -20,16 +20,9 @@ -type query_text() :: iolist() | binary(). -spec start_link( db_url() ) -> {ok, pid()}. --spec start_link( db_url(), [ conn_opt() ] ) -> {ok, pid()}. --spec ping( pid() ) -> {ok, #orca_ok{}} | {error, term()}. --spec sql( pid(), query_text() ) -> {ok, generic_response()} | {error, term()}. --spec sql( pid(), query_text(), [ term() ] ) -> {ok, generic_response()} | {error, term()}. --spec process_info( pid() ) -> {ok, #orca_rows{} | #orca_error{}} | {error, term()}. --spec process_kill( pid(), non_neg_integer() ) -> {ok, #orca_ok{} | #orca_error{}} | {error, term()}. --spec shutdown( pid(), Reason :: term() ) -> ok. - start_link( Url ) -> start_link( Url, [] ). +-spec start_link( db_url(), [ conn_opt() ] ) -> {ok, pid()}. start_link( Url, Opts ) -> {ok, ConnProps} = orca_url:parse( Url ), ConnHost = proplists:get_value( host, ConnProps ), @@ -69,6 +62,7 @@ start_link( Url, Opts ) -> err_packet -> {error, {auth, PropsAuthResult}} end. +-spec shutdown( pid(), Reason :: term() ) -> ok. shutdown( OrcaConn, Reason ) when is_pid( OrcaConn ) -> ok = orca_conn_srv:shutdown( OrcaConn, Reason ). @@ -76,11 +70,15 @@ init_db( C, Db ) -> {ok, ComInitDb} = orca_encoder_com:com_init_db( Db ), raw_packet_and_recv( C, ComInitDb ). +-spec ping( pid() ) -> {ok, #orca_ok{}} | {error, term()}. ping( C ) -> {ok, ComPing} = orca_encoder_com:com_ping(), raw_packet_and_recv( C, ComPing ). +-spec sql( pid(), query_text() ) -> {ok, generic_response()} | {error, term()}. sql( C, Q ) -> sql( C, Q, [] ). + +-spec sql( pid(), query_text(), [ term() ] ) -> {ok, generic_response()} | {error, term()}. sql( C, Q, A ) -> {ok, ComQuery} = orca_encoder_com:com_query( Q, A ), raw_packet_and_recv( C, ComQuery ). @@ -89,10 +87,12 @@ quit( C ) -> {ok, ComQuit} = orca_encoder_com:com_quit(), raw_packet_and_recv( C, ComQuit ). +-spec process_info( pid() ) -> {ok, #orca_rows{} | #orca_error{}} | {error, term()}. process_info( C ) -> {ok, ComProcessInfo} = orca_encoder_com:com_process_info(), raw_packet_and_recv( C, ComProcessInfo ). +-spec process_kill( pid(), non_neg_integer() ) -> {ok, #orca_ok{} | #orca_error{}} | {error, term()}. process_kill( C, ThreadID ) -> {ok, ComKill} = orca_encoder_com:com_process_kill( ThreadID ), raw_packet_and_recv( C, ComKill ). diff -Ndurp orca-0.1.11/src/orca_conn_mgr.erl orca-0.1.11-doc/src/orca_conn_mgr.erl --- orca-0.1.11/src/orca_conn_mgr.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_conn_mgr.erl 2017-05-21 17:13:55.032165877 +0300 @@ -37,12 +37,6 @@ {initial_queries_run_complete, WorkerPid}). -spec start_link( db_url(), [ conn_opt() ] ) -> {ok, pid()}. --spec shutdown( pid(), term() ) -> ok. --spec execute( pid(), binary() ) -> - {ok, {ok_packet | err_packet | result_set, [ {atom(), term()} ]}} | {error, term()}. --spec execute( pid(), binary(), timeout() ) -> - {ok, {ok_packet | err_packet | result_set, [ {atom(), term()} ]}} | {error, term()}. - start_link( Url, ConnOpts ) when is_binary( Url ) -> start_link( binary_to_list( Url ), ConnOpts ); start_link( Url = [ $m, $y, $s, $q, $l, $:, $/, $/ | _ ], ConnOpts ) -> @@ -63,12 +57,17 @@ start_link( Url = [ $m, $y, $s, $q, $l, ConnOpts ), proc_lib:start_link( ?MODULE, enter_loop, [InitArgs] ). +-spec shutdown( pid(), term() ) -> ok. shutdown( Srv, Reason ) -> gen_server:call( Srv, ?shutdown( Reason ) ). +-spec execute( pid(), binary() ) -> + {ok, {ok_packet | err_packet | result_set, [ {atom(), term()} ]}} | {error, term()}. execute( Srv, PacketBin ) -> execute_result( gen_server:call( Srv, ?execute( PacketBin ) ) ). +-spec execute( pid(), binary(), timeout() ) -> + {ok, {ok_packet | err_packet | result_set, [ {atom(), term()} ]}} | {error, term()}. execute( Srv, PacketBin, Timeout ) when is_pid( Srv ) andalso is_binary( PacketBin ) diff -Ndurp orca-0.1.11/src/orca_conn_mgr_lb.erl orca-0.1.11-doc/src/orca_conn_mgr_lb.erl --- orca-0.1.11/src/orca_conn_mgr_lb.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_conn_mgr_lb.erl 2017-05-21 17:14:41.414962245 +0300 @@ -21,17 +21,14 @@ -opaque ctx() :: #ctx{}. -spec new() -> {ok, ctx()}. --spec add( pid(), ctx() ) -> {ok, ctx()}. --spec rm( pid(), ctx() ) -> {ok, queue:queue( gen_reply_to() ), ctx()}. --spec job_in( gen_reply_to(), ctx() ) -> {ok, pid(), ctx()} | {error, no_workers}. --spec job_out( pid(), ctx() ) -> {ok, gen_reply_to(), ctx()}. - new() -> {ok, #ctx{}}. +-spec add( pid(), ctx() ) -> {ok, ctx()}. add( Pid, Ctx = #ctx{ workers = Ws0 } ) when is_pid( Pid ) -> Ws1 = [ #worker{ pid = Pid } | Ws0 ], {ok, Ctx #ctx{ workers = Ws1 }}. +-spec rm( pid(), ctx() ) -> {ok, queue:queue( gen_reply_to() ), ctx()}. rm(Pid, Ctx = #ctx{workers = Ws0}) when is_pid(Pid) -> case lists:keytake(Pid, #worker.pid, Ws0) of {value, #worker{ reply_to_queue = ReplyToQueue }, Ws1} -> @@ -40,13 +37,14 @@ rm(Pid, Ctx = #ctx{workers = Ws0}) when {ok, queue:new(), Ctx} end. - +-spec job_in( gen_reply_to(), ctx() ) -> {ok, pid(), ctx()} | {error, no_workers}. job_in( _, #ctx{ workers = [] } ) -> {error, no_workers}; job_in( GenReplyTo = {_, _}, Ctx = #ctx{ workers = [ W0 | Ws0 ] } ) -> {ok, W1} = worker_append_job( GenReplyTo, W0 ), {ok, Ws1} = worker_insert( W1, Ws0 ), {ok, W1 #worker.pid, Ctx #ctx{ workers = Ws1 }}. +-spec job_out( pid(), ctx() ) -> {ok, gen_reply_to(), ctx()}. job_out( Pid, Ctx = #ctx{ workers = Ws0 } ) -> {value, W0, Ws1} = lists:keytake( Pid, #worker.pid, Ws0 ), {ok, GenReplyTo, W1} = worker_fetch_job( W0 ), @@ -71,16 +69,13 @@ worker_insert( W = #worker{ reply_to_que -spec zip( left | right, fun(( [T], [T] ) -> boolean()), {[T], [T]} ) -> {[T], [T]}. --spec zip_right_till( fun(( [T], [T] ) -> boolean()), {[T], [T]} ) -> {[T], [T]}. --spec zip_left_till( fun(( [T], [T] ) -> boolean()), {[T], [T]} ) -> {[T], [T]}. - - zip( Direction, F, {L, R} ) -> case Direction of left -> zip_left_till( F, {L, R} ); right -> zip_right_till( F, {L, R} ) end. +-spec zip_right_till( fun(( [T], [T] ) -> boolean()), {[T], [T]} ) -> {[T], [T]}. zip_right_till( _, {L, []} ) -> {L, []}; zip_right_till( F, {L, CandR = [ C | R ]} ) -> case F(L, CandR) of @@ -88,6 +83,7 @@ zip_right_till( F, {L, CandR = [ C | R ] true -> zip_right_till( F, {[ C | L ], R} ) end. +-spec zip_left_till( fun(( [T], [T] ) -> boolean()), {[T], [T]} ) -> {[T], [T]}. zip_left_till( _, {[], R} ) -> {[], R}; zip_left_till( F, {CandL = [ C | L ], R} ) -> case F( CandL, R ) of diff -Ndurp orca-0.1.11/src/orca_conn_srv.erl orca-0.1.11-doc/src/orca_conn_srv.erl --- orca-0.1.11/src/orca_conn_srv.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_conn_srv.erl 2017-05-21 17:13:55.032165877 +0300 @@ -31,11 +31,6 @@ -define( hib_timeout, 5000 ). -spec start_link( [ conn_opt() ] ) -> {ok, pid()}. --spec set_active( pid(), once | true | false ) -> ok. --spec send_packet( pid(), non_neg_integer(), binary() ) -> ok. --spec recv_packet( pid() ) -> {ok, binary()} | {error, term()}. --spec shutdown( pid(), term() ) -> ok. - start_link( Opts0 ) when is_list( Opts0 ) -> Opts1 = opts_ensure_controlling_process( Opts0 ), proc_lib:start_link( ?MODULE, enter_loop, [ Opts1 ] ). @@ -54,12 +49,14 @@ tx_loop( Tcp ) -> tx_loop( Tcp ) end. +-spec set_active( pid(), once | true | false ) -> ok. set_active( Srv, Mode ) when (is_pid( Srv ) orelse is_atom( Srv )) andalso in( Mode, [ true, false, once ] ) -> ok = gen_server:cast( Srv, ?set_active( Mode ) ). +-spec send_packet( pid(), non_neg_integer(), binary() ) -> ok. send_packet( Srv, SeqID, Packet ) when is_pid( Srv ) andalso is_integer( SeqID ) andalso SeqID >= 0 andalso SeqID =< 255 @@ -67,9 +64,11 @@ send_packet( Srv, SeqID, Packet ) -> gen_server:cast( Srv, ?send_packet( SeqID, Packet ) ). +-spec recv_packet( pid() ) -> {ok, binary()} | {error, term()}. recv_packet( Srv ) when is_pid( Srv ) -> gen_server:call( Srv, ?recv_packet(), ?recv_default_timeout ). +-spec shutdown( pid(), term() ) -> ok. shutdown( Srv, Reason ) when is_pid( Srv ) -> gen_server:call( Srv, ?shutdown( Reason ) ). diff -Ndurp orca-0.1.11/src/orca_decoder_result_set.erl orca-0.1.11-doc/src/orca_decoder_result_set.erl --- orca-0.1.11/src/orca_decoder_result_set.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_decoder_result_set.erl 2017-05-21 17:13:55.032165877 +0300 @@ -74,10 +74,9 @@ decode_field_def( Bin0 ) -> -record(field, { col_type :: integer() }). --define(f(FieldName), FieldName = proplists:get_value( FieldName, Props ) ). def_props_to_record( Props ) -> #field{ - ?f(col_type) + col_type = proplists:get_value( col_type, Props ) }. decode_row_using_field_defs( FieldDefRecords, RowRaw ) -> diff -Ndurp orca-0.1.11/src/orca_encoder_handshake.erl orca-0.1.11-doc/src/orca_encoder_handshake.erl --- orca-0.1.11/src/orca_encoder_handshake.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_encoder_handshake.erl 2017-05-21 17:13:55.032165877 +0300 @@ -53,17 +53,16 @@ props_to_req( [ {PName, PValue} | Props props_to_req( Props, prop_set( PName, PValue, Req ) ). -define( guard_flags( Max ), ( is_integer( PValue ) andalso PValue >= 0 andalso PValue =< Max ) ). --define( prop( PN, Guard ), PN when Guard -> {ok, Req #req{ PN = PValue }} ). prop_set( PName, PValue, Req = #req{} ) -> case PName of - ?prop( server_version, is_binary( PValue ) ); - ?prop( connection_id, is_integer( PValue ) andalso PValue >= 0 ); - ?prop( auth_plugin_data_part_1, is_binary( PValue ) andalso erlang:byte_size( PValue ) == 8 ); - ?prop( cap_flags, ?guard_flags( 16#FFFFFFFF ) ); - ?prop( encoding, ?guard_flags( 16#FF ) ); - ?prop( status_flags, ?guard_flags( 16#FFFF ) ); - ?prop( auth_plugin_data_part_2, is_binary( PValue ) andalso erlang:byte_size( PValue ) == 13 ); - ?prop( auth_plugin_name, is_binary( PValue ) andalso PValue == ?MYSQL_NATIVE_PASSWORD ); + server_version when is_binary( PValue ) -> {ok, Req #req{ server_version = PValue }}; + connection_id when is_integer( PValue ) andalso PValue >= 0 -> {ok, Req #req{ connection_id = PValue }}; + auth_plugin_data_part_1 when is_binary( PValue ) andalso erlang:byte_size( PValue ) == 8 -> {ok, Req #req{ auth_plugin_data_part_1 = PValue }}; + cap_flags when ?guard_flags( 16#FFFFFFFF ) -> {ok, Req #req{ cap_flags = PValue }}; + encoding when ?guard_flags( 16#FF ) -> {ok, Req #req{ encoding = PValue }}; + status_flags when ?guard_flags( 16#FFFF ) -> {ok, Req #req{ status_flags = PValue }}; + auth_plugin_data_part_2 when is_binary( PValue ) andalso erlang:byte_size( PValue ) == 13 -> {ok, Req #req{ auth_plugin_data_part_2 = PValue }}; + auth_plugin_name when is_binary( PValue ) andalso PValue == ?MYSQL_NATIVE_PASSWORD -> {ok, Req #req{ auth_plugin_name = PValue }}; _ when in( PName, [ server_version, connection_id, auth_plugin_data_part_1, cap_flags, encoding, status_flags, diff -Ndurp orca-0.1.11/src/orca.erl orca-0.1.11-doc/src/orca.erl --- orca-0.1.11/src/orca.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca.erl 2017-05-21 17:13:55.032165877 +0300 @@ -20,15 +20,9 @@ -type query_text() :: iolist() | binary(). -spec start_link( db_url() ) -> {ok, pid()}. --spec start_link( db_url(), [ conn_opt() ] ) -> {ok, pid()}. --spec ping( pid() ) -> {ok, #orca_ok{}} | {error, term()}. --spec sql( pid(), query_text() ) -> {ok, generic_response()} | {error, term()}. --spec sql( pid(), query_text(), [ term() ] ) -> {ok, generic_response()} | {error, term()}. --spec process_info( pid() ) -> {ok, #orca_rows{} | #orca_error{}} | {error, term()}. --spec process_kill( pid(), non_neg_integer() ) -> {ok, #orca_ok{} | #orca_error{}} | {error, term()}. --spec shutdown( pid(), Reason :: term() ) -> ok. - start_link( Url ) -> start_link( Url, [] ). + +-spec start_link( db_url(), [ conn_opt() ] ) -> {ok, pid()}. start_link( Url, Opts ) -> orca_conn_mgr:start_link( Url, Opts ). await_ready( ConnMgr ) -> await_ready( ConnMgr, 5000, 100 ). @@ -41,17 +35,23 @@ await_ready( ConnMgr, Timeout, PingInter Deadline = Now + Timeout, await_ready_impl( ConnMgr, PingInterval, Deadline ). +-spec shutdown( pid(), Reason :: term() ) -> ok. shutdown( ConnMgr, Reason ) -> orca_conn_mgr:shutdown( ConnMgr, Reason ). +-spec ping( pid() ) -> {ok, #orca_ok{}} | {error, term()}. ping( ConnMgr ) -> {ok, ComPing} = orca_encoder_com:com_ping(), raw_packet( ConnMgr, ComPing ). +-spec sql( pid(), query_text() ) -> {ok, generic_response()} | {error, term()}. sql( ConnMgr, Query ) -> sql( ConnMgr, Query, [] ). + +-spec sql( pid(), query_text(), [ term() ] ) -> {ok, generic_response()} | {error, term()}. sql( ConnMgr, Query, Args ) -> {ok, ComQuery} = orca_encoder_com:com_query( Query, Args ), raw_packet( ConnMgr, ComQuery ). +-spec process_info( pid() ) -> {ok, #orca_rows{} | #orca_error{}} | {error, term()}. process_info( ConnMgr ) -> {ok, ComProcessInfo} = orca_encoder_com:com_process_info(), raw_packet( ConnMgr, ComProcessInfo ). @@ -63,6 +63,7 @@ process_info( ConnMgr ) -> % {ok, ComDropDb} = orca_encoder_com:com_drop_db( DbName ), % raw_packet( ConnMgr, ComDropDb ). +-spec process_kill( pid(), non_neg_integer() ) -> {ok, #orca_ok{} | #orca_error{}} | {error, term()}. process_kill( ConnMgr, ThreadID ) -> {ok, ComKill} = orca_encoder_com:com_process_kill( ThreadID ), raw_packet( ConnMgr, ComKill ). diff -Ndurp orca-0.1.11/src/orca_tcp.erl orca-0.1.11-doc/src/orca_tcp.erl --- orca-0.1.11/src/orca_tcp.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_tcp.erl 2017-05-21 17:13:55.032165877 +0300 @@ -13,13 +13,9 @@ -type conn() :: #orca_tcp{}. -export_type([ conn/0 ]). --spec open( inet_host(), inet_port() ) -> { ok, conn() } | {error, Reason :: term()}. --spec activate( conn() ) -> ok | {error, posix_error()}. --spec send( conn(), binary() | iolist() ) -> ok | {error, posix_error()}. --spec messages( conn() ) -> {atom(), atom(), atom(), term()}. - from_socket( Sock ) when is_port( Sock ) -> {ok, #orca_tcp{ sock = Sock }}. +-spec open( inet_host(), inet_port() ) -> { ok, conn() } | {error, Reason :: term()}. open( Host, Port ) when ?is_inet_port( Port ) -> case gen_tcp:connect( Host, Port, [ binary, {packet, raw}, {active, false}, {send_timeout, infinity} ] ) of {ok, Sock} -> @@ -29,6 +25,11 @@ open( Host, Port ) when ?is_inet_port( P {error, Reason} -> {error, Reason} end. +-spec activate( conn() ) -> ok | {error, posix_error()}. activate( #orca_tcp{ sock = Sock } ) -> inet:setopts( Sock, [ {active, once} ] ). + +-spec send( conn(), binary() | iolist() ) -> ok | {error, posix_error()}. send( #orca_tcp{ sock = Sock }, Data ) -> gen_tcp:send( Sock, Data ). + +-spec messages( conn() ) -> {atom(), atom(), atom(), term()}. messages( #orca_tcp{ sock = Sock } ) -> {tcp, tcp_closed, tcp_error, Sock}. diff -Ndurp orca-0.1.11/src/orca_type_decoder.erl orca-0.1.11-doc/src/orca_type_decoder.erl --- orca-0.1.11/src/orca_type_decoder.erl 2017-04-14 16:39:57.040509216 +0300 +++ orca-0.1.11-doc/src/orca_type_decoder.erl 2017-05-21 17:13:55.032165877 +0300 @@ -15,13 +15,6 @@ mysql_enc_string(). - --spec take( - Type :: mysql_enc_type(), PacketIn :: binary() -) -> - {ok, Value :: term(), PacketOut :: binary()} - | {error, Reason :: term()}. - take_seq( Types, BinIn ) when is_list( Types ) andalso is_binary( BinIn ) -> {QFinal, BinOut} = lists:foldl( fun( Type, {Q, Bin0} ) -> @@ -31,6 +24,12 @@ take_seq( Types, BinIn ) when is_list( T {queue:new(), BinIn}, Types ), { ok, queue:to_list( QFinal ), BinOut }. +-spec take( + Type :: mysql_enc_type(), PacketIn :: binary() +) -> + {ok, Value :: term(), PacketOut :: binary()} + | {error, Reason :: term()}. + take( {int, lenenc}, BinIn ) -> case BinIn of <<16#FC:8/integer, IntValue:16/little, BinOut/binary>> -> {ok, IntValue, BinOut};
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor