@@ -2,13 +2,32 @@ defmodule Ch do
22 @ moduledoc "Minimal HTTP ClickHouse client."
33 alias Ch . { Connection , Query , Result }
44
5+ @ typedoc """
6+ Options shared by both connection startup and query execution.
7+
8+ * `:database` - Database, defaults to `"default"`
9+ * `:username` - Username
10+ * `:password` - User password
11+ * `:settings` - Keyword list of ClickHouse settings
12+ * `:timeout` - HTTP request/receive timeout in milliseconds
13+ """
514 @ type common_option ::
615 { :database , String . t ( ) }
716 | { :username , String . t ( ) }
817 | { :password , String . t ( ) }
918 | { :settings , Keyword . t ( ) }
1019 | { :timeout , timeout }
1120
21+ @ typedoc """
22+ Options for starting the connection pool.
23+
24+ Includes all keys from `t:common_option/0` and `t:DBConnection.start_option/0` plus:
25+
26+ * `:scheme` - HTTP scheme, defaults to `"http"`
27+ * `:hostname` - server hostname, defaults to `"localhost"`
28+ * `:port` - HTTP port, defaults to `8123`
29+ * `:transport_opts` - options to be given to the transport being used. See `Mint.HTTP1.connect/4` for more info
30+ """
1231 @ type start_option ::
1332 common_option
1433 | { :scheme , String . t ( ) }
@@ -18,38 +37,36 @@ defmodule Ch do
1837 | DBConnection . start_option ( )
1938
2039 @ doc """
21- Start the connection process and connect to ClickHouse.
22-
23- ## Options
24-
25- * `:scheme` - HTTP scheme, defaults to `"http"`
26- * `:hostname` - server hostname, defaults to `"localhost"`
27- * `:port` - HTTP port, defaults to `8123`
28- * `:transport_opts` - options to be given to the transport being used. See `Mint.HTTP1.connect/4` for more info
29- * `:database` - Database, defaults to `"default"`
30- * `:username` - Username
31- * `:password` - User password
32- * `:settings` - Keyword list of ClickHouse settings
33- * `:timeout` - HTTP receive timeout in milliseconds
34- * `:transport_opts` - options to be given to the transport being used. See `Mint.HTTP1.connect/4` for more info
35- * [`DBConnection.start_option()`](https://hexdocs.pm/db_connection/DBConnection.html#t:start_option/0)
40+ Start the connection pool process.
3641
42+ See `t:start_option/0` for available options.
3743 """
3844 @ spec start_link ( [ start_option ] ) :: GenServer . on_start ( )
3945 def start_link ( opts \\ [ ] ) do
4046 DBConnection . start_link ( Connection , opts )
4147 end
4248
4349 @ doc """
44- Returns a supervisor child specification for a DBConnection pool.
50+ Returns a supervisor child specification for a connection pool.
4551
46- See `start_link/1 ` for supported options.
52+ See `t:start_option/0 ` for supported options.
4753 """
4854 @ spec child_spec ( [ start_option ] ) :: :supervisor . child_spec ( )
4955 def child_spec ( opts ) do
5056 DBConnection . child_spec ( Connection , opts )
5157 end
5258
59+ @ typedoc """
60+ Options for executing a query.
61+
62+ Includes all keys from `t:common_option/0` and `t:DBConnection.connection_option/0` plus:
63+
64+ * `:command` - Command tag for the query
65+ * `:headers` - Custom HTTP headers for the request
66+ * `:format` - Custom response format for the request
67+ * `:decode` - Whether to automatically decode the response
68+ * `:multipart` - Whether to send the query as multipart/form-data
69+ """
5370 @ type query_option ::
5471 common_option
5572 | { :command , Ch.Query . command ( ) }
@@ -66,20 +83,7 @@ defmodule Ch do
6683 Runs a query and returns the result as `{:ok, %Ch.Result{}}` or
6784 `{:error, Exception.t()}` if there was a database error.
6885
69- ## Options
70-
71- * `:database` - Database
72- * `:username` - Username
73- * `:password` - User password
74- * `:settings` - Keyword list of settings
75- * `:timeout` - Query request timeout
76- * `:command` - Command tag for the query
77- * `:headers` - Custom HTTP headers for the request
78- * `:format` - Custom response format for the request
79- * `:decode` - Whether to automatically decode the response
80- * `:multipart` - Whether to send the query as multipart/form-data
81- * [`DBConnection.connection_option()`](https://hexdocs.pm/db_connection/DBConnection.html#t:connection_option/0)
82-
86+ See `t:query_option/0` for available options.
8387 """
8488 @ spec query ( DBConnection . conn ( ) , iodata , params , [ query_option ] ) ::
8589 { :ok , Result . t ( ) } | { :error , Exception . t ( ) }
0 commit comments