Skip to content

Commit e839dd6

Browse files
Merge pull request #52 from stackql/feature/static-analysis-v4
enhanced-static-analysis
2 parents dc58e94 + a3985e4 commit e839dd6

File tree

9 files changed

+398
-152
lines changed

9 files changed

+398
-152
lines changed

anysdk/address_space.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package anysdk
22

33
type AddressSpaceExpansionConfig interface {
4+
IsAsync() bool
45
IsLegacy() bool
56
IsAllowNilResponse() bool
67
}

anysdk/request.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,27 @@ import (
1313
"github.com/stackql/any-sdk/pkg/streaming"
1414
)
1515

16+
type HTTPPreparatorConfig interface {
17+
IsFromAnnotation() bool
18+
}
19+
20+
type standardHTTPPreparatorConfig struct {
21+
isFromAnnotation bool
22+
}
23+
24+
func (cfg *standardHTTPPreparatorConfig) IsFromAnnotation() bool {
25+
return cfg.isFromAnnotation
26+
}
27+
28+
func NewHTTPPreparatorConfig(isFromAnnotation bool) HTTPPreparatorConfig {
29+
return &standardHTTPPreparatorConfig{
30+
isFromAnnotation: isFromAnnotation,
31+
}
32+
}
33+
1634
type HTTPPreparator interface {
17-
BuildHTTPRequestCtx() (HTTPArmoury, error)
18-
BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error)
35+
BuildHTTPRequestCtx(HTTPPreparatorConfig) (HTTPArmoury, error)
36+
// BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error)
1937
}
2038

2139
type standardHTTPPreparator struct {
@@ -65,7 +83,10 @@ func newHTTPPreparator(
6583
}
6684

6785
//nolint:funlen,gocognit // TODO: review
68-
func (pr *standardHTTPPreparator) BuildHTTPRequestCtx() (HTTPArmoury, error) {
86+
func (pr *standardHTTPPreparator) BuildHTTPRequestCtx(cfg HTTPPreparatorConfig) (HTTPArmoury, error) {
87+
if cfg.IsFromAnnotation() {
88+
return pr.buildHTTPRequestCtxFromAnnotation()
89+
}
6990
method, methodOk := pr.m.(StandardOperationStore)
7091
if !methodOk {
7192
return nil, fmt.Errorf("operation store is not a standard operation store")
@@ -209,7 +230,7 @@ func getRequest(
209230
}
210231

211232
//nolint:funlen,gocognit // acceptable
212-
func (pr *standardHTTPPreparator) BuildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error) {
233+
func (pr *standardHTTPPreparator) buildHTTPRequestCtxFromAnnotation() (HTTPArmoury, error) {
213234
var err error
214235
httpArmoury := NewHTTPArmoury()
215236
var requestSchema, responseSchema Schema

cmd/argparse/query.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ func runQueryCommand(authCtx *dto.AuthCtx, payload *queryCmdPayload) error {
195195
}
196196
return nil
197197
case client.HTTP:
198+
var isFromAnnotation bool = false // TODO: publish something meaningful here
198199
prep := anysdk.NewHTTPPreparator(
199200
prov,
200201
svc,
@@ -206,7 +207,7 @@ func runQueryCommand(authCtx *dto.AuthCtx, payload *queryCmdPayload) error {
206207
execCtx,
207208
getLogger(),
208209
)
209-
armoury, err := prep.BuildHTTPRequestCtx()
210+
armoury, err := prep.BuildHTTPRequestCtx(anysdk.NewHTTPPreparatorConfig(isFromAnnotation))
210211
if err != nil {
211212
return err
212213
}

docs/protocol_agnostic/gRPC.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
2+
3+
# gRPC
4+
5+
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.
6+
7+
This is based upon [grpcurl](https://github.com/fullstorydev/grpcurl).
8+
9+
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`.
10+
11+
## Bankdemo example
12+
13+
14+
Build bankdemo to current dir:
15+
16+
```bash
17+
18+
go build -o bankdemo "${HOME}/stackql/grpcurl/internal/testing/cmd/bankdemo"
19+
20+
21+
```
22+
23+
24+
Basic request response:
25+
26+
27+
28+
```bash
29+
grpcurl -plaintext -H 'Authorization: token joeblow' -d '{ "initial_deposit_cents": 20, "type": 2 }' 127.0.0.1:12345 Bank/OpenAccount
30+
```
31+
32+
```json
33+
{
34+
"accountNumber": "1",
35+
"type": "SAVING",
36+
"balanceCents": 20
37+
}
38+
```
39+
40+
```bash
41+
grpcurl -plaintext -H 'Authorization: token joeblow' 127.0.0.1:12345 Bank/GetAccounts
42+
```
43+
44+
```json
45+
{
46+
"accounts": [
47+
{
48+
"accountNumber": "1",
49+
"type": "SAVING",
50+
"balanceCents": 20
51+
}
52+
]
53+
}
54+
```
55+
56+
Results in:
57+
58+
```json
59+
60+
{
61+
"accountNumber": "1",
62+
"type": "SAVING",
63+
"balanceCents": 20
64+
}
65+
66+
```
67+
68+
Then:
69+
70+
```bash
71+
72+
73+
74+
```
75+
76+
77+
Full Duplex streaming:
78+
79+
80+
```bash
81+
82+
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
83+
84+
```
85+
86+
When starting a new session, server writes:
87+
88+
```json
89+
{
90+
"session": {
91+
"sessionId": "000002",
92+
"customerName": "joeblow"
93+
}
94+
}
95+
```
96+
97+
When rejoining an existing session, eg:
98+
99+
Eg
100+
101+
```bash
102+
103+
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
104+
105+
```
106+
107+
Server writes:
108+
109+
```json
110+
111+
112+
{
113+
"session": {
114+
"sessionId": "000006",
115+
"customerName": "joeblow",
116+
"history": [
117+
{
118+
"date": "2025-09-17T07:29:37.764312Z",
119+
"customerMsg": "Hello I am angry!"
120+
},
121+
{
122+
"date": "2025-09-17T07:29:37.764314Z",
123+
"customerMsg": "Can you please fix my account?"
124+
},
125+
{
126+
"date": "2025-09-17T07:31:13.941966Z",
127+
"customerMsg": "Hello again I am now somewhat calm."
128+
}
129+
]
130+
}
131+
}
132+
133+
```
134+

0 commit comments

Comments
 (0)