Skip to content

Commit 5d2feb3

Browse files
Merge pull request #32 from splitio/rename_socket_path_option
Rename `:socket_path` option and Bump version to 1.0.0
2 parents ad599b2 + 55e34da commit 5d2feb3

File tree

12 files changed

+61
-63
lines changed

12 files changed

+61
-63
lines changed

CHANGES.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
0.2.1 (February 24, 2025):
1+
1.0.0 (February 25, 2025):
22
- Fixed the SDK language version to correctly reflect the package version when it's installed from hex.pm.
3+
- BREAKING CHANGES:
4+
- Renamed the `:socket_path` option to `:address` in `Split.Supervisor.start_link/1`.
35

46
0.2.0 (February 14, 2025):
57
- Added new variations of the get treatment functions to support evaluating flags in given flag set/s: `Split.get_treatments_by_flag_set/3`, `Split.get_treatments_by_flag_sets/3`, `Split.get_treatments_with_config_by_flag_set/3`, and `Split.get_treatments_with_config_by_flag_sets/3`.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Split SDK for Elixir
22

3-
[![hex.pm version](https://img.shields.io/hexpm/v/split_thin_sdk)](https://img.shields.io/hexpm/v/split_thin_sdk) [![Build Status](https://github.com/splitio/elixir-thin-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/splitio/elixir-thin-client/actions/workflows/ci-cd.yml) [![Greenkeeper badge](https://badges.greenkeeper.io/splitio/elixir-thin-client.svg)](https://greenkeeper.io/)
3+
[![hex.pm version](https://img.shields.io/hexpm/v/split_thin_sdk)](https://img.shields.io/hexpm/v/split_thin_sdk) [![Build Status](https://github.com/splitio/elixir-thin-client/actions/workflows/ci.yml/badge.svg)](https://github.com/splitio/elixir-thin-client/actions/workflows/ci-cd.yml) [![Greenkeeper badge](https://badges.greenkeeper.io/splitio/elixir-thin-client.svg)](https://greenkeeper.io/)
44

55
## Overview
66
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.
@@ -36,7 +36,7 @@ Below is a simple example that describes the instantiation and most basic usage
3636

3737
```elixir
3838
# Start the SDK supervisor
39-
Split.Supervisor.start_link(socket_path: "/var/run/splitd.sock")
39+
Split.Supervisor.start_link(address: "/var/run/splitd.sock")
4040

4141
# Get treatment for a user
4242
case Split.get_treatment(user_id, feature_flag_name) do

lib/split.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule Split do
1616
def start(_type, _args) do
1717
children = [
1818
# ... other children ...
19-
{Split, [socket_path: "/var/run/split.sock"]}
19+
{Split, [address: "/var/run/split.sock"]}
2020
]
2121
2222
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
@@ -32,7 +32,7 @@ defmodule Split do
3232
3333
`Split` takes a number of keyword arguments as options when starting. The following options are available:
3434
35-
- `:socket_path`: **OPTIONAL** The path to the splitd socket file. Default is `"/var/run/splitd.sock"`.
35+
- `:address`: **OPTIONAL** The path to the splitd socket file. Default is `"/var/run/splitd.sock"`.
3636
- `:pool_size`: **OPTIONAL** The size of the pool of connections to the splitd daemon. Default is the number of online schedulers in the Erlang VM (See: https://www.erlang.org/doc/apps/erts/erl_cmd.html).
3737
- `:connect_timeout`: **OPTIONAL** The timeout in milliseconds to connect to the splitd daemon. Default is `1000`.
3838
@@ -52,7 +52,7 @@ defmodule Split do
5252

5353
@typedoc "An option that can be provided when starting `Split`. See [options](#module-options) for more information."
5454
@type option ::
55-
{:socket_path, String.t()}
55+
{:address, String.t()}
5656
| {:pool_size, non_neg_integer()}
5757
| {:connect_timeout, non_neg_integer()}
5858

lib/split/rpc/message.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Split.RPC.Message do
55
use Split.RPC.Opcodes
66

77
@protocol_version 0x01
8-
@client_id "Splitd_Elixir-0.2.1-rc.0"
8+
@client_id "Splitd_Elixir-1.0.0"
99

1010
@type opcode :: unquote(Enum.reduce(@opcodes, &{:|, [], [&1, &2]}))
1111
@type protocol_version :: unquote(@protocol_version)
@@ -37,7 +37,7 @@ defmodule Split.RPC.Message do
3737
## Examples
3838
3939
iex> Message.register()
40-
%Message{v: 1, o: 0, a: ["123", "Splitd_Elixir-0.2.1-rc.0", 1]}
40+
%Message{v: 1, o: 0, a: ["123", "Splitd_Elixir-1.0.0", 1]}
4141
"""
4242
@spec register() :: t()
4343
def register, do: %__MODULE__{o: @register_opcode, a: ["123", @client_id, 1]}

lib/split/sockets/conn.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ defmodule Split.Sockets.Conn do
99

1010
@type t :: %__MODULE__{
1111
socket: port() | nil,
12-
socket_path: String.t(),
12+
address: String.t(),
1313
opts: keyword()
1414
}
1515

1616
defstruct [
1717
:socket,
18-
:socket_path,
18+
:address,
1919
:opts
2020
]
2121

@@ -31,20 +31,20 @@ defmodule Split.Sockets.Conn do
3131
@default_rcv_timeout 1000
3232

3333
@spec new(String.t(), keyword()) :: t
34-
def new(socket_path, opts \\ []) do
34+
def new(address, opts \\ []) do
3535
%__MODULE__{
3636
socket: nil,
37-
socket_path: socket_path,
37+
address: address,
3838
opts: opts
3939
}
4040
end
4141

4242
@spec connect(t) :: {:ok, t()} | {:error, t(), term()}
43-
def connect(%__MODULE__{socket: nil, socket_path: socket_path, opts: opts} = conn) do
43+
def connect(%__MODULE__{socket: nil, address: address, opts: opts} = conn) do
4444
connect_timeout = Keyword.get(opts, :connect_timeout, @default_connect_timeout)
4545

46-
Telemetry.span(:connect, %{socket_path: socket_path, pool_name: opts[:pool_name]}, fn ->
47-
case :gen_tcp.connect({:local, socket_path}, 0, @connect_opts, connect_timeout) do
46+
Telemetry.span(:connect, %{address: address, pool_name: opts[:pool_name]}, fn ->
47+
case :gen_tcp.connect({:local, address}, 0, @connect_opts, connect_timeout) do
4848
{:ok, socket} ->
4949
conn = %{conn | socket: socket}
5050

lib/split/sockets/pool.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ defmodule Split.Sockets.Pool do
1717
end
1818

1919
def start_link(opts) do
20-
socket_path = Keyword.get(opts, :socket_path, "/var/run/splitd.sock")
20+
address = Keyword.get(opts, :address, "/var/run/splitd.sock")
2121
pool_name = Keyword.get(opts, :pool_name, __MODULE__)
2222
pool_size = Keyword.get(opts, :pool_size, System.schedulers_online())
2323

2424
opts =
2525
opts
26-
|> Keyword.put_new(:socket_path, socket_path)
26+
|> Keyword.put_new(:address, address)
2727
|> Keyword.put_new(:pool_size, pool_size)
2828
|> Keyword.put_new(:pool_name, pool_name)
2929

@@ -100,11 +100,11 @@ defmodule Split.Sockets.Pool do
100100

101101
@impl NimblePool
102102
def init_pool(opts) do
103-
socket_path = Keyword.get(opts, :socket_path)
103+
address = Keyword.get(opts, :address)
104104

105-
unless File.exists?(socket_path) do
105+
unless File.exists?(address) do
106106
Logger.error("""
107-
The Split Daemon (splitd) socket was not found at #{socket_path}.
107+
The Split Daemon (splitd) socket was not found at address #{address}.
108108
109109
This is likely because the Splitd daemon is not running.
110110
""")
@@ -117,7 +117,7 @@ defmodule Split.Sockets.Pool do
117117

118118
@impl NimblePool
119119
def init_worker({opts, _metrics_ref} = pool_state) do
120-
{:ok, Conn.new(Keyword.get(opts, :socket_path), opts), pool_state}
120+
{:ok, Conn.new(Keyword.get(opts, :address), opts), pool_state}
121121
end
122122

123123
@impl NimblePool

lib/split/telemetry.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ defmodule Split.Telemetry do
100100
101101
#### Metadata
102102
103-
* `socket_path` - The path to the socket file.
103+
* `address` - The path to the socket file.
104104
* `pool_name` - The name of the pool being used.
105105
106106
### Connect Stop
@@ -114,7 +114,7 @@ defmodule Split.Telemetry do
114114
115115
#### Metadata
116116
117-
* `socket_path` - The path to the socket file.
117+
* `address` - The path to the socket file.
118118
* `pool_name` - The name of the pool being used.
119119
* `error` - The error message if the connection fails.
120120

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule SplitThinElixir.MixProject do
44
def project do
55
[
66
app: :split,
7-
version: "0.2.1-rc.0",
7+
version: "1.0.0",
88
elixir: "~> 1.14",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,

test/sockets/conn_test.exs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ defmodule Split.Sockets.ConnTest do
99
describe "telemetry events" do
1010
setup context do
1111
test_id = :erlang.phash2(context.test)
12-
socket_path = "/tmp/test-splitd-#{test_id}.sock"
12+
address = "/tmp/test-splitd-#{test_id}.sock"
1313
process_name = :"test-#{test_id}"
1414

1515
start_supervised!(
16-
{Split.Test.MockSplitdServer, socket_path: socket_path, name: process_name},
16+
{Split.Test.MockSplitdServer, address: address, name: process_name},
1717
id: process_name,
1818
restart: :transient
1919
)
2020

21-
Split.Test.MockSplitdServer.wait_until_listening(socket_path)
21+
Split.Test.MockSplitdServer.wait_until_listening(address)
2222

23-
{:ok, socket_path: socket_path, splitd_name: process_name}
23+
{:ok, address: address, splitd_name: process_name}
2424
end
2525

26-
test "emits telemetry events for successful connection", %{socket_path: socket_path} do
26+
test "emits telemetry events for successful connection", %{address: address} do
2727
ref =
2828
:telemetry_test.attach_event_handlers(self(), [
2929
[:split, :connect, :start],
3030
[:split, :connect, :stop]
3131
])
3232

33-
Conn.new(socket_path) |> Conn.connect()
33+
Conn.new(address) |> Conn.connect()
3434

35-
assert_received {[:split, :connect, :start], ^ref, _, %{socket_path: ^socket_path}}
35+
assert_received {[:split, :connect, :start], ^ref, _, %{address: ^address}}
3636
assert_received {[:split, :connect, :stop], ^ref, _, %{}}
3737
end
3838

39-
test "emits telemetry events for registration message on connect", %{socket_path: socket_path} do
39+
test "emits telemetry events for registration message on connect", %{address: address} do
4040
ref =
4141
:telemetry_test.attach_event_handlers(self(), [
4242
[:split, :send, :start],
@@ -45,7 +45,7 @@ defmodule Split.Sockets.ConnTest do
4545
[:split, :receive, :stop]
4646
])
4747

48-
Conn.new(socket_path) |> Conn.connect()
48+
Conn.new(address) |> Conn.connect()
4949

5050
assert_received {[:split, :send, :start], ^ref, _,
5151
%{request: %Message{v: 1, o: @register_opcode}}}
@@ -59,7 +59,7 @@ defmodule Split.Sockets.ConnTest do
5959
end
6060

6161
test "emits telemetry events for failed connection", %{
62-
socket_path: socket_path,
62+
address: address,
6363
splitd_name: splitd_name
6464
} do
6565
ref =
@@ -71,21 +71,21 @@ defmodule Split.Sockets.ConnTest do
7171
# Stop the mocked splitd socket to receive connection errors
7272
:ok = stop_supervised(splitd_name)
7373

74-
assert {:error, _conn, reason} = Conn.new(socket_path) |> Conn.connect()
74+
assert {:error, _conn, reason} = Conn.new(address) |> Conn.connect()
7575

76-
assert_received {[:split, :connect, :start], ^ref, _, %{socket_path: ^socket_path}}
76+
assert_received {[:split, :connect, :start], ^ref, _, %{address: ^address}}
7777

7878
assert_received {[:split, :connect, :stop], ^ref, _, %{error: ^reason}}
7979
end
8080

81-
test "emits telemetry events for successful message sending", %{socket_path: socket_path} do
81+
test "emits telemetry events for successful message sending", %{address: address} do
8282
ref =
8383
:telemetry_test.attach_event_handlers(self(), [
8484
[:split, :send, :start],
8585
[:split, :send, :stop]
8686
])
8787

88-
{:ok, conn} = Conn.new(socket_path) |> Conn.connect()
88+
{:ok, conn} = Conn.new(address) |> Conn.connect()
8989

9090
message = Message.get_treatment(key: "user-id", feature_name: "feature")
9191

@@ -97,7 +97,7 @@ defmodule Split.Sockets.ConnTest do
9797
end
9898

9999
test "emits telemetry events for failed message sending", %{
100-
socket_path: socket_path,
100+
address: address,
101101
splitd_name: splitd_name
102102
} do
103103
ref =
@@ -106,7 +106,7 @@ defmodule Split.Sockets.ConnTest do
106106
[:split, :send, :stop]
107107
])
108108

109-
{:ok, conn} = Conn.new(socket_path) |> Conn.connect()
109+
{:ok, conn} = Conn.new(address) |> Conn.connect()
110110

111111
message = Message.get_treatment(key: "user-id", feature_name: "feature")
112112

@@ -120,14 +120,14 @@ defmodule Split.Sockets.ConnTest do
120120
assert_received {[:split, :send, :stop], ^ref, _, %{error: ^reason}}
121121
end
122122

123-
test "emits telemetry events for successful message receiving", %{socket_path: socket_path} do
123+
test "emits telemetry events for successful message receiving", %{address: address} do
124124
ref =
125125
:telemetry_test.attach_event_handlers(self(), [
126126
[:split, :receive, :start],
127127
[:split, :receive, :stop]
128128
])
129129

130-
{:ok, conn} = Conn.new(socket_path) |> Conn.connect()
130+
{:ok, conn} = Conn.new(address) |> Conn.connect()
131131

132132
message = Message.get_treatment(key: "user-id", feature_name: "feature")
133133

@@ -138,14 +138,14 @@ defmodule Split.Sockets.ConnTest do
138138
assert_received {[:split, :receive, :stop], ^ref, _, %{response: ^response}}
139139
end
140140

141-
test "emits telemetry events for failed message receiving", %{socket_path: socket_path} do
141+
test "emits telemetry events for failed message receiving", %{address: address} do
142142
ref =
143143
:telemetry_test.attach_event_handlers(self(), [
144144
[:split, :receive, :start],
145145
[:split, :receive, :stop]
146146
])
147147

148-
{:ok, conn} = Conn.new(socket_path) |> Conn.connect()
148+
{:ok, conn} = Conn.new(address) |> Conn.connect()
149149

150150
# receive the registration messages
151151
assert_received {[:split, :receive, :start], ^ref, _, %{}}

test/sockets/pool_test.exs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ defmodule Split.Sockets.PoolTest do
99

1010
setup_all context do
1111
test_id = :erlang.phash2(context.module)
12-
socket_path = "/tmp/test-splitd-#{test_id}.sock"
12+
address = "/tmp/test-splitd-#{test_id}.sock"
1313

14-
start_supervised!(
15-
{Split.Test.MockSplitdServer, socket_path: socket_path, name: :"test-#{test_id}"}
16-
)
14+
start_supervised!({Split.Test.MockSplitdServer, address: address, name: :"test-#{test_id}"})
1715

18-
Split.Test.MockSplitdServer.wait_until_listening(socket_path)
16+
Split.Test.MockSplitdServer.wait_until_listening(address)
1917

20-
start_supervised!({Split, socket_path: socket_path, pool_name: __MODULE__, pool_size: 10})
18+
start_supervised!({Split, address: address, pool_name: __MODULE__, pool_size: 10})
2119

2220
:ok
2321
end

0 commit comments

Comments
 (0)