Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
1831516
setup project plan
brenbar Oct 19, 2025
3032f5f
wip
brenbar Oct 19, 2025
3ee6065
wip
brenbar Oct 19, 2025
374cbf3
wip
brenbar Oct 19, 2025
3c34293
wip
brenbar Oct 19, 2025
0c49410
wip
brenbar Oct 19, 2025
bce8a6f
wip
brenbar Oct 19, 2025
e788034
wip
brenbar Oct 19, 2025
3971515
wip
brenbar Oct 19, 2025
311c366
wip
brenbar Oct 19, 2025
df8cc68
wip
brenbar Oct 19, 2025
a904cc9
wip
brenbar Oct 19, 2025
57932a3
wip
brenbar Oct 19, 2025
e1fc06a
wip
brenbar Oct 19, 2025
fd0b8b5
wip
brenbar Oct 19, 2025
c2a6bcb
wip
brenbar Oct 19, 2025
3d19690
wip
brenbar Oct 19, 2025
abc6157
wip
brenbar Oct 20, 2025
857e249
wip
brenbar Oct 20, 2025
083f6ff
wip
brenbar Oct 22, 2025
9d8374c
wip
brenbar Oct 22, 2025
8904a0b
wip
brenbar Oct 23, 2025
ff253bc
wip
brenbar Oct 23, 2025
aa6c2fd
wip
brenbar Oct 23, 2025
a46e5d8
wip
brenbar Oct 23, 2025
8d168b0
wip
brenbar Oct 23, 2025
c663386
wip
brenbar Oct 23, 2025
1165ad0
Try to setup test scaffold
brenbar Oct 24, 2025
50da933
wip
brenbar Oct 24, 2025
d091f2f
wip: make test-trace-go passing
brenbar Oct 24, 2025
93a11bf
Fix a few tests
brenbar Oct 24, 2025
3c6d341
wip: all go server tests passing
brenbar Oct 24, 2025
28c5748
Make binary tests pass
brenbar Oct 24, 2025
0e3b2d4
wip: go schema tests passing
brenbar Oct 24, 2025
7132c75
wip: go binary client server tests passing
brenbar Oct 24, 2025
954c494
Fix mock tests
brenbar Oct 24, 2025
140c375
wip: go mock multi tests passing
brenbar Oct 25, 2025
16c2056
wip: first but wrong attempt at go codegen
brenbar Oct 25, 2025
475f6fd
wip: iterate on go codegen
brenbar Oct 25, 2025
35a970c
wip: all go tests passing maybe
brenbar Oct 25, 2025
50ca812
wip: maybe
brenbar Oct 25, 2025
ad9d790
wip: maybe this time
brenbar Oct 25, 2025
9907f3b
Remove test binaries
brenbar Oct 25, 2025
53ab133
Remove ai plans
brenbar Oct 25, 2025
2ec25d7
Merge branch 'main' of github.com:Telepact/telepact into go5
brenbar Oct 25, 2025
0dedd13
Add readme
brenbar Oct 25, 2025
6447098
Fix map nondeterminism
brenbar Oct 26, 2025
5f37227
wip: all go tests passing maybe
brenbar Oct 27, 2025
4a561ef
Merge branch 'main' of github.com:Telepact/telepact into go5
brenbar Oct 27, 2025
baab552
Consolidate test harness files
brenbar Oct 28, 2025
10882c9
Refine code order
brenbar Oct 28, 2025
9284452
Delete tests
brenbar Oct 28, 2025
15d3a71
Rename
brenbar Oct 28, 2025
2b1482b
Move files up
brenbar Oct 28, 2025
945aad9
todo: fix opt duplicate nondeterminism
brenbar Oct 28, 2025
7406875
Merge branch 'main' of github.com:Telepact/telepact into go5
brenbar Oct 29, 2025
1d4d4a1
Merge branch 'main' of github.com:Telepact/telepact into go5
brenbar Nov 1, 2025
a463979
Switch path collision to duplicate field
brenbar Nov 1, 2025
2787d35
rerun
brenbar Nov 1, 2025
3e65dfd
rerun
brenbar Nov 1, 2025
a47b66f
Move top-level files to pkg
brenbar Nov 1, 2025
297dda6
Revert "Move top-level files to pkg"
brenbar Nov 1, 2025
dd61fad
Add publish logic
brenbar Nov 1, 2025
245a8dd
Git commit common json in go library
brenbar Nov 2, 2025
9344c18
Add checks
brenbar Nov 2, 2025
5689f8d
Remove unnecessary cli command
brenbar Nov 2, 2025
80fc3d7
Refine message
brenbar Nov 2, 2025
274d348
cleanup
brenbar Nov 2, 2025
3f90f1f
Support go in project recognition
brenbar Nov 2, 2025
91e1f19
Update docs
brenbar Nov 2, 2025
75e3e31
Merge branch 'main' of github.com:Telepact/telepact into go5
brenbar Nov 3, 2025
c4efdaf
Add go build step
brenbar Nov 3, 2025
3822b66
Remove unused variables
brenbar Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document provides guidance for AI agents working within the Telepact codeba
Telepact is a multi-language API ecosystem built around a unified schema definition. The core idea is to define your API in `.telepact.json` files, and then use language-specific libraries to implement clients and servers.

The project is a monorepo containing several independent but related components:
- **Core Libraries (`/lib`)**: Implementations of the Telepact protocol in `java`, `py` (Python), and `ts` (TypeScript). These provide the `Server` and `Client` classes.
- **Core Libraries (`/lib`)**: Implementations of the Telepact protocol in `go`, `java`, `py` (Python), and `ts` (TypeScript). These provide the `Server` and `Client` classes.
- **SDKs (`/sdk`)**: Tools built on top of the core libraries, including a `cli`, a web-based `console`, and a `prettier` plugin for formatting schema files.
- **Bindings (`/bind`)**: Language-specific bindings, like for `dart`.
- **Schema Definitions**: APIs are defined in `.telepact.json` files (e.g., `common/auth.telepact.json`). These files are the source of truth for all API interactions.
Expand All @@ -20,7 +20,6 @@ The entire project uses a hierarchical `Makefile` system. The root `Makefile` de

### Building

- To build everything: `make` (though this is often not necessary).
- To build a specific library, navigate to its directory or use the root makefile. For example, to build the Java library:
```sh
make java
Expand All @@ -31,33 +30,18 @@ The entire project uses a hierarchical `Makefile` system. The root `Makefile` de

### Testing

The central test runner is located in `/test/runner`, which is a Python project. It is responsible for orchestrating tests across all language libraries to ensure they are interoperable.

- To run all tests:
```sh
make test
```
- To run tests for a specific language:
- Run tests from the `/test/runner` directory:
```sh
make test-java
make test-py
make test-ts
poetry run python -m pytest -s -vv -k <test_name>
```
- When in the `/test/runner` directory, you can run tests directly with `poetry run python -m pytest`.

- To run a single test case (e.g., for debugging), use `pytest`'s `-k` option to select a test by name. The `test/runner/Makefile` has `test-trace-*` targets that are good examples:
```sh
# From the root directory
make test-trace-java

# Or, from the test/runner directory
poetry run python -m pytest -k test_client_server_case[java-0] -s -vv
```
- NOTE: You need the `-s` flag to show all request/response payloads for debugging.
HOWEVER, avoid using `-s` when `-k` is not specified, as it will produce excessive output.

### Key Files & Directories

- `Makefile`: The entry point for all build, test, and deploy operations.
- `lib/{java,py,ts}`: The core libraries. Changes here impact the fundamental behavior of Telepact.
- `lib/{go,java,py,ts}`: The core libraries. Changes here impact the fundamental behavior of Telepact.
- `bind/dart`: Language-specific bindings for Dart.
- `test/runner`: The cross-language integration test suite. This is the best place to understand how different language implementations are expected to behave and interact.
- `common/*.telepact.json`: The common schema files that define the internal APIs used by Telepact itself.
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ jobs:
path: lib/java/target
retention-days: 1

build-go:
name: Build Go
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Build go
run: make go

build-py:
name: Build Python
runs-on: ubuntu-latest
Expand Down Expand Up @@ -382,7 +398,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [build-ts, build-java, build-py, build-cli]
needs: [build-ts, build-java, build-go, build-py, build-cli]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ jobs:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: make deploy-py

publish-go:
runs-on: ubuntu-latest
if: ${{ contains(github.event.release.body, '- go') }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Publish to Go proxy
run: make deploy-go

publish-cli:
runs-on: ubuntu-latest
if: ${{ contains(github.event.release.body, '- cli') }}
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ test-trace-ts:
deploy-ts:
$(MAKE) -C lib/ts deploy

go:
$(MAKE) -C lib/go

clean-go:
$(MAKE) -C lib/go clean

test-go:
$(MAKE) -C test/runner test-go

test-trace-go:
$(MAKE) -C test/runner test-trace-go

deploy-go:
$(MAKE) -C lib/go deploy

.PHONY: test
test:
$(MAKE) -C test/runner test
Expand All @@ -72,6 +87,7 @@ clean-test:
$(MAKE) -C test/runner clean
$(MAKE) -C test/lib/java clean
$(MAKE) -C test/lib/py clean
$(MAKE) -C test/lib/go clean
$(MAKE) -C test/lib/ts clean

dart:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ the library and SDK docs:
- [Library: Typescript](./lib/ts/README.md)
- [Library: Python](./lib/py/README.md)
- [Library: Java](./lib/java/README.md)
- [Library: Go](./lib/go/README.md)

- [SDK: CLI](./sdk/cli/README.md)
- [SDK: Developer Console](./sdk/console/README.md)
Expand Down
133 changes: 133 additions & 0 deletions lib/go/Client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
//|
//| Copyright The Telepact Authors
//|
//| Licensed under the Apache License, Version 2.0 (the "License");
//| you may not use this file except in compliance with the License.
//| You may obtain a copy of the License at
//|
//| https://www.apache.org/licenses/LICENSE-2.0
//|
//| Unless required by applicable law or agreed to in writing, software
//| distributed under the License is distributed on an "AS IS" BASIS,
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//| See the License for the specific language governing permissions and
//| limitations under the License.
//|

package telepact

import (
"context"
"errors"
"fmt"

telepactinternal "github.com/telepact/telepact/lib/go/internal"
"github.com/telepact/telepact/lib/go/internal/binary"
)

// ClientAdapter is the transport-specific function used to exchange Telepact messages.
type ClientAdapter func(ctx context.Context, request Message, serializer *Serializer) (Message, error)

// ClientOptions configure a Client instance.
type ClientOptions struct {
UseBinary bool
AlwaysSendJSON bool
TimeoutMSDefault int
SerializationImpl Serialization
}

// NewClientOptions returns a ClientOptions struct populated with library defaults.
func NewClientOptions() *ClientOptions {
return &ClientOptions{
UseBinary: false,
AlwaysSendJSON: true,
TimeoutMSDefault: 5000,
SerializationImpl: NewDefaultSerialization(),
}
}

// Client coordinates request/response interactions with a Telepact service.
type Client struct {
adapter ClientAdapter
useBinaryDefault bool
alwaysSendJSON bool
timeoutMSDefault int
serializer *Serializer
}

// NewClient constructs a Client using the provided adapter and options.
func NewClient(adapter ClientAdapter, options *ClientOptions) (*Client, error) {
if adapter == nil {
return nil, errors.New("telepact: client adapter must not be nil")
}

if options == nil {
options = NewClientOptions()
}

serializationImpl := options.SerializationImpl
if serializationImpl == nil {
serializationImpl = NewDefaultSerialization()
}

binaryEncodingCache := binary.NewDefaultBinaryEncodingCache()
binaryEncoder := binary.NewClientBinaryEncoder(binaryEncodingCache)
base64Encoder := binary.NewClientBase64Encoder()
serializer := NewSerializer(serializationImpl, binaryEncoder, base64Encoder)

return &Client{
adapter: adapter,
useBinaryDefault: options.UseBinary,
alwaysSendJSON: options.AlwaysSendJSON,
timeoutMSDefault: options.TimeoutMSDefault,
serializer: serializer,
}, nil
}

// RequestWithContext executes the adapter using the supplied context, applying Telepact defaults.
func (c *Client) RequestWithContext(ctx context.Context, request Message) (Message, error) {
if c == nil {
return Message{}, NewTelepactError("telepact: client is nil")
}

if ctx == nil {
ctx = context.Background()
}

internalRequest := telepactinternal.NewClientMessage(request.Headers, request.Body)

adapter := func(ctx context.Context, msg *telepactinternal.ClientMessage) (*telepactinternal.ClientMessage, error) {
resp, err := c.adapter(ctx, Message{Headers: msg.Headers, Body: msg.Body}, c.serializer)
if err != nil {
return nil, err
}
return telepactinternal.NewClientMessage(resp.Headers, resp.Body), nil
}

internalResponse, err := telepactinternal.ClientHandleMessage(
ctx,
internalRequest,
adapter,
c.timeoutMSDefault,
c.useBinaryDefault,
c.alwaysSendJSON,
)
if err != nil {
return Message{}, NewTelepactError(fmt.Sprintf("client request failed: %v", err))
}

return Message{Headers: internalResponse.Headers, Body: internalResponse.Body}, nil
}

// Request executes the adapter using a background context.
func (c *Client) Request(request Message) (Message, error) {
return c.RequestWithContext(context.Background(), request)
}

// Serializer returns the serializer associated with the client.
func (c *Client) Serializer() *Serializer {
if c == nil {
return nil
}
return c.serializer
}
Loading
Loading