Skip to content

Add connect() client mode and Japanese README#2

Merged
Moge800 merged 3 commits into
mainfrom
claude/wizardly-allen-lnrqxf
Jun 27, 2026
Merged

Add connect() client mode and Japanese README#2
Moge800 merged 3 commits into
mainfrom
claude/wizardly-allen-lnrqxf

Conversation

@Moge800

@Moge800 Moge800 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

One package now covers both "bundle and run the server" and "just be a client", over the same PLCClient:

  • connect(base_url, token=None) — talk to a gomc-rest server already running elsewhere (another machine, a shared instance, or one started with server_mode=True) without spawning the bundled binary. Returns a PLCClient and supports the context-manager protocol.
  • Existing launch() (bundle + auto-start, private by default or exposed via server_mode=True) is unchanged.

This reuses gomc-rest-client — no protocol or HTTP-client reimplementation, so there is no second source of truth to keep in sync.

import gomc_rest

# bundled server, private (loopback)
with gomc_rest.launch(plc_host="192.168.0.1") as plc:
    plc.read("D100", 3)

# client only: connect to an existing server
with gomc_rest.connect("http://192.168.0.1:8080", token="...") as plc:
    plc.read("D100", 3)

Changes

  • src/gomc_rest/__init__.py: add connect(), export it, update module docstring.
  • README.md / README_JP.md: document the client mode; add a Japanese README with an English/日本語 cross-link.

Notes

  • No dependency or behavior change to launch().
  • connect() is a thin wrapper over PLCClient(base_url, token=...).

🤖 Generated with Claude Code


Generated by Claude Code

claude added 3 commits June 27, 2026 10:44
One package now exposes both entry points over the same PLCClient: launch()
spawns the bundled server (private or exposed via server_mode), and connect()
talks to a gomc-rest server already running elsewhere without starting the
binary. Re-uses gomc-rest-client; no protocol/client reimplementation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SQbVkPEprK2ebcjck5ouUy
… tests

P1: publish a binary-free sdist alongside the platform wheels so client-only
users on platforms without a prebuilt wheel (macOS, Windows arm64, glibc <
2.34) can still 'pip install gomc-rest' and use connect(); launch() then raises
a clear error. Document this in both READMEs.

P2: use an absolute URL for the README_JP link so it resolves in the PyPI long
description (relative repo links break there).

Tests: add tests/test_connect.py pinning that connect() returns a PLCClient,
forwards base_url and token, and never spawns a subprocess.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SQbVkPEprK2ebcjck5ouUy
@Moge800 Moge800 merged commit 4bbf6cd into main Jun 27, 2026
2 checks passed
@Moge800 Moge800 deleted the claude/wizardly-allen-lnrqxf branch June 27, 2026 11:27
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