Skip to content

Add TestServer.TCP#58

Draft
richard-ash wants to merge 1 commit into
mainfrom
richard/add-tcp
Draft

Add TestServer.TCP#58
richard-ash wants to merge 1 commit into
mainfrom
richard/add-tcp

Conversation

@richard-ash

Copy link
Copy Markdown
Collaborator

No description provided.

Base automatically changed from richard/add-ssh to main May 21, 2026 01:01
@richard-ash richard-ash force-pushed the richard/add-tcp branch 5 times, most recently from 75c5759 to 4e3d05e Compare May 25, 2026 04:53
Comment thread lib/test_server/tcp.ex
Comment thread lib/test_server/tcp/server.ex Outdated
@richard-ash richard-ash force-pushed the richard/add-tcp branch 3 times, most recently from 1e0893b to 4f7a37d Compare May 27, 2026 21:23
Comment thread lib/test_server/tcp/instance.ex Outdated
Comment thread lib/test_server/tcp.ex Outdated
Comment thread README.md Outdated
@richard-ash richard-ash force-pushed the richard/add-tcp branch 2 times, most recently from 77b349d to b77449c Compare May 31, 2026 00:12
Comment thread lib/test_server/tcp/instance.ex Outdated
@richard-ash richard-ash force-pushed the richard/add-tcp branch 3 times, most recently from f5fca44 to b796fa9 Compare June 2, 2026 23:06
Comment thread lib/test_server/tcp/server.ex Outdated
Comment thread lib/test_server/tcp.ex
Comment thread CHANGELOG.md Outdated
Comment thread lib/test_server/tcp.ex Outdated
Comment thread lib/test_server/tcp/instance.ex Outdated
Comment thread lib/test_server/tcp.ex Outdated
Comment on lines +59 to +62
@spec connections(TestServer.instance()) :: [map()]
def connections(instance) do
GenServer.call(instance, :connections)
end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is used.

Comment on lines +81 to +85
@spec report_error(TestServer.instance(), {struct(), TestServer.stacktrace()}) :: :ok
def report_error(instance, {exception, stacktrace}) do
options = get_options(instance)
report_error_with_options(options, {exception, stacktrace})
end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird, shouldn't it be like how it looks in HTTP and SSH? We should probably DRY it up as well after.

Comment thread lib/test_server/tcp/instance.ex Outdated
Comment thread lib/test_server/tcp/instance.ex Outdated
Comment thread lib/test_server/tcp/instance.ex Outdated
report_error_with_options(state.options, {exception, stacktrace})

message = Exception.format(:error, exception, stacktrace)
:gen_tcp.send(connection.socket, message)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to do any direct gen tcp stuf fhere, it should just pass-thru to the TCP layer or server if that. I think the general idea should be that instance just handles handler/match calls, while the actual execution is defined in the handler itself somewhere else. In this case we can wrap the function with gen_tcp send, or have it done after?

Comment thread lib/test_server/tcp/instance.ex Outdated
Comment on lines +136 to +141
state.connections
|> Enum.reduce(state, fn connection, state ->
connection
|> run_send_handler(to, stacktrace)
|> send_response(connection, state)
end)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads odd, why run it on all connections instead of just having this being single connection in the first place? I guess we can support multi connections but if we do that we should make it more explicit.

@richard-ash richard-ash force-pushed the richard/add-tcp branch 3 times, most recently from c445600 to 6a8914a Compare June 12, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants