Skip to content

Commit 8a2ddf8

Browse files
committed
fix(dispatch): send source over wire and cleanup attr definitions
1 parent e074bf4 commit 8a2ddf8

File tree

18 files changed

+81
-77
lines changed

18 files changed

+81
-77
lines changed

api/http_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ func TestHTTPClient(t *testing.T) {
7878
httpClient.Address = sURL.Host
7979
httpClient.Protocol = "http"
8080

81-
err = httpClient.CallRaw(ctx, lib.AEHome, nil, &bytes.Buffer{})
81+
err = httpClient.CallRaw(ctx, lib.AEHome, "", nil, &bytes.Buffer{})
8282
if err != nil {
8383
t.Fatal(err.Error())
8484
}
8585

8686
res := []dsref.VersionInfo{}
8787
p := lib.ListParams{}
88-
err = httpClient.CallMethod(ctx, lib.AEList, http.MethodPost, p, &res)
88+
err = httpClient.CallMethod(ctx, lib.AEList, http.MethodPost, "", p, &res)
8989
if err != nil {
9090
t.Fatal(err.Error())
9191
}

lib/access.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (m AccessMethods) Name() string {
2222
// Attributes defines attributes for each method
2323
func (m AccessMethods) Attributes() map[string]AttributeSet {
2424
return map[string]AttributeSet{
25-
"createauthtoken": {AECreateAuthToken, "GET", "local"},
25+
"createauthtoken": {endpoint: AECreateAuthToken, httpVerb: "GET", defaultSource: "local"},
2626
}
2727
}
2828

lib/automation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (m AutomationMethods) Name() string {
2626
// Attributes defines attributes for each method
2727
func (m AutomationMethods) Attributes() map[string]AttributeSet {
2828
return map[string]AttributeSet{
29-
"apply": {AEApply, "POST", ""},
29+
"apply": {endpoint: AEApply, httpVerb: "POST"},
3030
}
3131
}
3232

lib/collection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func (m CollectionMethods) Name() string {
2727
// Attributes defines attributes for each method
2828
func (m CollectionMethods) Attributes() map[string]AttributeSet {
2929
return map[string]AttributeSet{
30-
"list": {AEList, "POST", ""},
31-
"listrawrefs": {denyRPC, "", ""},
30+
"list": {endpoint: AEList, httpVerb: "POST"},
31+
"listrawrefs": {endpoint: denyRPC},
3232
}
3333
}
3434

lib/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func (m ConfigMethods) Name() string {
2525
func (m ConfigMethods) Attributes() map[string]AttributeSet {
2626
return map[string]AttributeSet{
2727
// config methods are not allowed over HTTP nor RPC
28-
"getconfig": {denyRPC, "", ""},
29-
"getconfigkeys": {denyRPC, "", ""},
30-
"setconfig": {denyRPC, "", ""},
28+
"getconfig": {endpoint: denyRPC},
29+
"getconfigkeys": {endpoint: denyRPC},
30+
"setconfig": {endpoint: denyRPC},
3131
}
3232
}
3333

lib/datasets.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ func (m DatasetMethods) Name() string {
5050
// Attributes defines attributes for each method
5151
func (m DatasetMethods) Attributes() map[string]AttributeSet {
5252
return map[string]AttributeSet{
53-
"componentstatus": {AEComponentStatus, "POST", ""},
54-
"get": {AEGet, "GET", ""},
55-
// "log": {AELog, "POST"},
56-
"rename": {AERename, "POST", ""},
57-
"save": {AESave, "POST", ""},
58-
"pull": {AEPull, "POST", "network"},
59-
// "push": {AEPush, "POST"},
60-
"render": {AERender, "POST", ""},
61-
"remove": {AERemove, "POST", "local"},
62-
"validate": {AEValidate, "POST", ""},
63-
// "unpack": {AEUnpack, "POST"},
64-
"manifest": {AEManifest, "POST", ""},
65-
"manifestmissing": {AEManifestMissing, "POST", ""},
66-
"daginfo": {AEDAGInfo, "POST", ""},
53+
"componentstatus": {endpoint: AEComponentStatus, httpVerb: "POST"},
54+
"get": {endpoint: AEGet, httpVerb: "GET"},
55+
// "log": {endpoint: AELog, httpVerb: "POST"},
56+
"rename": {endpoint: AERename, httpVerb: "POST", defaultSource: "local"},
57+
"save": {endpoint: AESave, httpVerb: "POST"},
58+
"pull": {endpoint: AEPull, httpVerb: "POST", defaultSource: "network"},
59+
// "push": {endpoint: AEPush, httpVerb: "POST", defaultSource: "local"},
60+
"render": {endpoint: AERender, httpVerb: "POST"},
61+
"remove": {endpoint: AERemove, httpVerb: "POST", defaultSource: "local"},
62+
"validate": {endpoint: AEValidate, httpVerb: "POST", defaultSource: "local"},
63+
// "unpack": {endpoint: AEUnpack, httpVerb: "POST"},
64+
"manifest": {endpoint: AEManifest, httpVerb: "POST"},
65+
"manifestmissing": {endpoint: AEManifestMissing, httpVerb: "POST"},
66+
"daginfo": {endpoint: AEDAGInfo, httpVerb: "POST"},
6767
}
6868
}
6969

lib/diff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func (m DiffMethods) Name() string {
2626
// Attributes defines attributes for each method
2727
func (m DiffMethods) Attributes() map[string]AttributeSet {
2828
return map[string]AttributeSet{
29-
"changes": {AEChanges, "POST", ""},
30-
"diff": {AEDiff, "POST", ""},
29+
"changes": {endpoint: AEChanges, httpVerb: "POST"},
30+
"diff": {endpoint: AEDiff, httpVerb: "POST"},
3131
}
3232
}
3333

lib/dispatch.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ func (inst *Instance) dispatchMethodCall(ctx context.Context, method string, par
122122
out := reflect.New(c.OutType)
123123
res = out.Interface()
124124
}
125-
// TODO(dustmop): Send the source across the RPC, using an HTTP header
126125
// TODO(ramfox): dispatch is still unable to give enough details to the url
127126
// (because it doesn't know how or what param information to put into the url or query)
128127
// for it to reliably use GET. All POSTs w/ content type application json work, however.
129128
// we may want to just flat out say that as an RPC layer, dispatch will only ever use
130129
// json POST to communicate.
131-
err = inst.http.CallMethod(ctx, c.Endpoint, "POST", param, res)
130+
err = inst.http.CallMethod(ctx, c.Endpoint, "POST", source, param, res)
132131
if err != nil {
133132
return nil, nil, err
134133
}

lib/dispatch_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ func (m *animalMethods) Name() string {
308308

309309
func (m *animalMethods) Attributes() map[string]AttributeSet {
310310
return map[string]AttributeSet{
311-
"cat": {denyRPC, "", ""},
312-
"dog": {denyRPC, "", ""},
311+
"cat": {endpoint: denyRPC},
312+
"dog": {endpoint: denyRPC},
313313
}
314314
}
315315

@@ -406,12 +406,12 @@ func (m *fruitMethods) Name() string {
406406

407407
func (m *fruitMethods) Attributes() map[string]AttributeSet {
408408
return map[string]AttributeSet{
409-
"apple": {"/apple", "GET", ""},
410-
"banana": {"/banana", "GET", ""},
411-
"cherry": {"/cherry", "GET", ""},
412-
"date": {"/date", "GET", ""},
409+
"apple": {endpoint: "/apple", httpVerb: "GET"},
410+
"banana": {endpoint: "/banana", httpVerb: "GET"},
411+
"cherry": {endpoint: "/cherry", httpVerb: "GET"},
412+
"date": {endpoint: "/date", httpVerb: "GET"},
413413
// entawak cannot be called over RPC
414-
"entawak": {denyRPC, "", ""},
414+
"entawak": {endpoint: denyRPC},
415415
}
416416
}
417417

@@ -489,8 +489,8 @@ func (m *getSrcMethods) Name() string {
489489

490490
func (m *getSrcMethods) Attributes() map[string]AttributeSet {
491491
return map[string]AttributeSet{
492-
"one": {"/one", "GET", ""},
493-
"two": {"/two", "GET", "network"},
492+
"one": {endpoint: "/one", httpVerb: "GET"},
493+
"two": {endpoint: "/two", httpVerb: "GET", defaultSource: "network"},
494494
}
495495
}
496496

lib/fsi.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ func (m FSIMethods) Name() string {
2929
// Attributes defines attributes for each method
3030
func (m FSIMethods) Attributes() map[string]AttributeSet {
3131
return map[string]AttributeSet{
32-
"status": {AEStatus, "POST", ""},
33-
"caninitdatasetworkdir": {AECanInitDatasetWorkDir, "POST", ""},
34-
"init": {AEInit, "POST", ""},
35-
"checkout": {AECheckout, "POST", ""},
36-
"ensureref": {AEEnsureRef, "POST", ""},
37-
"restore": {AERestore, "POST", ""},
38-
"write": {AEFSIWrite, "POST", ""},
39-
"createlink": {AEFSICreateLink, "POST", ""},
40-
"unlink": {AEFSIUnlink, "POST", ""},
32+
"status": {endpoint: AEStatus, httpVerb: "POST"},
33+
"caninitdatasetworkdir": {endpoint: AECanInitDatasetWorkDir, httpVerb: "POST"},
34+
"init": {endpoint: AEInit, httpVerb: "POST"},
35+
"checkout": {endpoint: AECheckout, httpVerb: "POST"},
36+
"ensureref": {endpoint: AEEnsureRef, httpVerb: "POST"},
37+
"restore": {endpoint: AERestore, httpVerb: "POST"},
38+
"write": {endpoint: AEFSIWrite, httpVerb: "POST"},
39+
"createlink": {endpoint: AEFSICreateLink, httpVerb: "POST"},
40+
"unlink": {endpoint: AEFSIUnlink, httpVerb: "POST"},
4141
}
4242
}
4343

0 commit comments

Comments
 (0)