Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions anysdk/address_space.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package anysdk

type AddressSpaceExpansionConfig interface {
IsAsync() bool
IsLegacy() bool
IsAllowNilResponse() bool
}
Expand Down
29 changes: 25 additions & 4 deletions anysdk/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,27 @@ import (
"github.com/stackql/any-sdk/pkg/streaming"
)

type HTTPPreparatorConfig interface {
IsFromAnnotation() bool
}

type standardHTTPPreparatorConfig struct {
isFromAnnotation bool
}

func (cfg *standardHTTPPreparatorConfig) IsFromAnnotation() bool {
return cfg.isFromAnnotation
}

func NewHTTPPreparatorConfig(isFromAnnotation bool) HTTPPreparatorConfig {
return &standardHTTPPreparatorConfig{
isFromAnnotation: isFromAnnotation,
}
}

type HTTPPreparator interface {
BuildHTTPRequestCtx() (HTTPArmoury, error)
BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error)
BuildHTTPRequestCtx(HTTPPreparatorConfig) (HTTPArmoury, error)
// BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error)
}

type standardHTTPPreparator struct {
Expand Down Expand Up @@ -65,7 +83,10 @@ func newHTTPPreparator(
}

//nolint:funlen,gocognit // TODO: review
func (pr *standardHTTPPreparator) BuildHTTPRequestCtx() (HTTPArmoury, error) {
func (pr *standardHTTPPreparator) BuildHTTPRequestCtx(cfg HTTPPreparatorConfig) (HTTPArmoury, error) {
if cfg.IsFromAnnotation() {
return pr.buildHTTPRequestCtxFromAnnotation()
}
method, methodOk := pr.m.(StandardOperationStore)
if !methodOk {
return nil, fmt.Errorf("operation store is not a standard operation store")
Expand Down Expand Up @@ -209,7 +230,7 @@ func getRequest(
}

//nolint:funlen,gocognit // acceptable
func (pr *standardHTTPPreparator) BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error) {
func (pr *standardHTTPPreparator) buildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error) {
var err error
httpArmoury := NewHTTPArmoury()
var requestSchema, responseSchema Schema
Expand Down
3 changes: 2 additions & 1 deletion cmd/argparse/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func runQueryCommand(authCtx *dto.AuthCtx, payload *queryCmdPayload) error {
}
return nil
case client.HTTP:
var isFromAnnotation bool = false // TODO: publish something meaningful here
prep := anysdk.NewHTTPPreparator(
prov,
svc,
Expand All @@ -206,7 +207,7 @@ func runQueryCommand(authCtx *dto.AuthCtx, payload *queryCmdPayload) error {
execCtx,
getLogger(),
)
armoury, err := prep.BuildHTTPRequestCtx()
armoury, err := prep.BuildHTTPRequestCtx(anysdk.NewHTTPPreparatorConfig(isFromAnnotation))
if err != nil {
return err
}
Expand Down
134 changes: 134 additions & 0 deletions docs/protocol_agnostic/gRPC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@


# gRPC

At this point in time, this is not implemented. However, it will be; gRPC is fully tractable with the requisite `.proto` files; compilation is not required. Effectively, the RPC concept is ignored and it becomes an abstraction on protocol buffer communication.

This is based upon [grpcurl](https://github.com/fullstorydev/grpcurl).

For convenience following examples, please clone `fullstorydev/grpcurl` into `${HOME}/stackql/grpcurl`, eg with `mkdir -p ${HOME}/stackql/grpcurl && git clone https://github.com/fullstorydev/grpcurl`.

## Bankdemo example


Build bankdemo to current dir:

```bash

go build -o bankdemo "${HOME}/stackql/grpcurl/internal/testing/cmd/bankdemo"


```


Basic request response:



```bash
grpcurl -plaintext -H 'Authorization: token joeblow' -d '{ "initial_deposit_cents": 20, "type": 2 }' 127.0.0.1:12345 Bank/OpenAccount
```

```json
{
"accountNumber": "1",
"type": "SAVING",
"balanceCents": 20
}
```

```bash
grpcurl -plaintext -H 'Authorization: token joeblow' 127.0.0.1:12345 Bank/GetAccounts
```

```json
{
"accounts": [
{
"accountNumber": "1",
"type": "SAVING",
"balanceCents": 20
}
]
}
```

Results in:

```json

{
"accountNumber": "1",
"type": "SAVING",
"balanceCents": 20
}

```

Then:

```bash



```


Full Duplex streaming:


```bash

grpcurl -plaintext -H 'Authorization: token joeblow' -d '{ "init": {} }' -import-path ${HOME}/stackql/grpcurl/internal/testing/cmd/bankdemo -proto support.proto 127.0.0.1:12345 Support/ChatCustomer

```

When starting a new session, server writes:

```json
{
"session": {
"sessionId": "000002",
"customerName": "joeblow"
}
}
```

When rejoining an existing session, eg:

Eg

```bash

grpcurl -plaintext -H 'Authorization: token joeblow' -d '{ "init": { "resume_session_id": "000002" } } { "msg": "Hello I am angry!" } {"hang_up": 0 } { "init": { "resume_session_id": "000002" } } ' -import-path ${HOME}/stackql/grpcurl/internal/testing/cmd/bankdemo -proto support.proto 127.0.0.1:12345 Support/ChatCustomer

```

Server writes:

```json


{
"session": {
"sessionId": "000006",
"customerName": "joeblow",
"history": [
{
"date": "2025-09-17T07:29:37.764312Z",
"customerMsg": "Hello I am angry!"
},
{
"date": "2025-09-17T07:29:37.764314Z",
"customerMsg": "Can you please fix my account?"
},
{
"date": "2025-09-17T07:31:13.941966Z",
"customerMsg": "Hello again I am now somewhat calm."
}
]
}
}

```

Loading
Loading