Skip to content

Commit a2e7829

Browse files
Merge pull request #33 from splitio/development
Release v1.0.0
2 parents 6e0c8c9 + 5d2feb3 commit a2e7829

File tree

14 files changed

+92
-62
lines changed

14 files changed

+92
-62
lines changed

.github/hooks/pre-push

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
elixir scripts/validate_version.exs
4+
5+
if [ $? -ne 0 ]; then
6+
exit 1
7+
fi

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.0.0 (February 25, 2025):
2+
- 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`.
5+
16
0.2.0 (February 14, 2025):
27
- 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`.
38
- Updated the `:socket_path` option for `Split.Supervisor.start_link/1` to be optional, defaulting to `"/var/run/splitd.sock"`.

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-" <> to_string(Application.spec(:split, :vsn))
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-", 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.0",
7+
version: "1.0.0",
88
elixir: "~> 1.14",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,

scripts/validate_version.exs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env elixir
2+
3+
# Read mix.exs version
4+
{:ok, mix_content} = File.read("mix.exs")
5+
version = Regex.run(~r/version: "([^"]+)"/, mix_content)
6+
|> Enum.at(1)
7+
8+
# Read message.ex @client_id
9+
{:ok, message_content} = File.read("lib/split/rpc/message.ex")
10+
client_id_version = Regex.run(~r/@client_id "Splitd_Elixir-([^"]+)"/, message_content)
11+
|> Enum.at(1)
12+
13+
if version != client_id_version do
14+
IO.puts :stderr, """
15+
Error: Version mismatch!
16+
mix.exs version: #{version}
17+
message.ex @client_id version: #{client_id_version}
18+
19+
Please update the @client_id in lib/split/rpc/message.ex to match the version in mix.exs
20+
"""
21+
System.halt(1)
22+
end

0 commit comments

Comments
 (0)