David Reiss | 6d47759 | 2008-06-11 01:12:09 +0000 | [diff] [blame] | 1 | -module(test_disklog). |
| 2 | |
| 3 | -compile(export_all). |
| 4 | |
| 5 | t() -> |
| 6 | {ok, TransportFactory} = |
| 7 | thrift_disk_log_transport:new_transport_factory( |
| 8 | test_disklog, |
| 9 | [{file, "/tmp/test_log"}, |
| 10 | {size, {1024*1024, 10}}]), |
| 11 | {ok, ProtocolFactory} = thrift_binary_protocol:new_protocol_factory( |
| 12 | TransportFactory, []), |
| 13 | {ok, Client} = thrift_client:start_link(ProtocolFactory, thriftTest_thrift), |
| 14 | |
| 15 | io:format("Client started~n"), |
David Reiss | 65cf720 | 2008-06-11 01:12:20 +0000 | [diff] [blame^] | 16 | |
David Reiss | 6d47759 | 2008-06-11 01:12:09 +0000 | [diff] [blame] | 17 | % We have to make async calls into this client only since otherwise it will try |
| 18 | % to read from the disklog and go boom. |
| 19 | {ok, ok} = thrift_client:call(Client, testAsync, [16#deadbeef]), |
| 20 | io:format("Call written~n"), |
| 21 | |
David Reiss | 65cf720 | 2008-06-11 01:12:20 +0000 | [diff] [blame^] | 22 | % Use the send_call method to write a non-async call into the log |
| 23 | ok = thrift_client:send_call(Client, testString, [<<"hello world">>]), |
| 24 | io:format("Non-async call sent~n"), |
| 25 | |
David Reiss | 6d47759 | 2008-06-11 01:12:09 +0000 | [diff] [blame] | 26 | ok = thrift_client:close(Client), |
| 27 | io:format("Client closed~n"), |
| 28 | |
| 29 | ok. |
| 30 | |