Skip to content

Commit

Permalink
added explicit async flag
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Aug 15, 2024
1 parent 9c02aea commit f85cf14
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 24 deletions.
20 changes: 0 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1083,14 +1083,6 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/viant/aerospike v0.1.2-0.20240730200051-419efba9f72a h1:k/5XkAnohrnDobwE1+l2wvQE+8IlsNpC/xdXaomruy8=
github.com/viant/aerospike v0.1.2-0.20240730200051-419efba9f72a/go.mod h1:0bFTo5IjbRAk8NpeX0F4GExehaz7BzyuVYDw8uLSews=
github.com/viant/aerospike v0.2.2 h1:y4kJQno55TLQ1lwDZjW3PXpida9qh23JoqfUQQgg/qI=
github.com/viant/aerospike v0.2.2/go.mod h1:KqvpFoMh5VqsGB7joznlVzVebiSir/8KjFTMqBvO4po=
github.com/viant/aerospike v0.2.3-0.20240809193156-a96832e8254e h1:lObh/8aaSX3SjWzdRbHmAcmiNNPUVnxtKPqM2rrIK2U=
github.com/viant/aerospike v0.2.3-0.20240809193156-a96832e8254e/go.mod h1:KqvpFoMh5VqsGB7joznlVzVebiSir/8KjFTMqBvO4po=
github.com/viant/aerospike v0.2.4-0.20240810131957-aca7e08594ac h1:E0jCTnwoO5B6gUJ7SWyPJaP0sRG1bWjfTJXlxPAuL34=
github.com/viant/aerospike v0.2.4-0.20240810131957-aca7e08594ac/go.mod h1:3Xw7jzP8bvJjRdTPV/TsM9lGEIyj3bPxbvmIVhfCU5E=
github.com/viant/aerospike v0.2.4 h1:sMZk5iutLASDQRwIK6lkX0G/s5Ki85G0oj1UcSE3T4E=
github.com/viant/aerospike v0.2.4/go.mod h1:3Xw7jzP8bvJjRdTPV/TsM9lGEIyj3bPxbvmIVhfCU5E=
github.com/viant/afs v1.25.1-0.20231110184132-877ed98abca1 h1:q83rO9rKNCsT/W9x9EBmCVt24yjFDRmhslLhaL4h7DE=
Expand Down Expand Up @@ -1123,20 +1115,12 @@ github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b h1:3q166tV28yFdbFV+
github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b/go.mod h1:85fneXJbErKMGhSQto3A5ElTQCwl3t74U9cSV0waBHw=
github.com/viant/pgo v0.11.0 h1:PNuYVhwTfyrAHGBO6lxaMFuHP4NkjKV8ULecz3OWk8c=
github.com/viant/pgo v0.11.0/go.mod h1:MFzHmkRFZlciugEgUvpl/3grK789PBSH4dUVSLOSo+Q=
github.com/viant/scy v0.11.0 h1:wkn+R29QJUJRGTRvJ4rQkq/dDpkeIVJyzgTz7+UVD+k=
github.com/viant/scy v0.11.0/go.mod h1:Lz1VPlmjVi4ydZ5ikP/d5uQS/xYs22HG23++PgLRlKQ=
github.com/viant/scy v0.11.1-0.20240809212619-84029a5e3755 h1:sWN+z/MrbhborVF9NhdQl8LMnHkotZNAkx/aTScanAA=
github.com/viant/scy v0.11.1-0.20240809212619-84029a5e3755/go.mod h1:Lz1VPlmjVi4ydZ5ikP/d5uQS/xYs22HG23++PgLRlKQ=
github.com/viant/sqlparser v0.7.1-0.20240717151907-216ea35d127a h1:2ijg6j7HlXU6S1gHAfWPLJ7x4Dqo1OgIlJU2niKK59s=
github.com/viant/sqlparser v0.7.1-0.20240717151907-216ea35d127a/go.mod h1:2QRGiGZYk2/pjhORGG1zLVQ9JO+bXFhqIVi31mkCRPg=
github.com/viant/sqlparser v0.7.1-0.20240805161001-5b3b5b7479ae h1:TLEFVQ4ffLSYaf1LXxZuJ8nQBNiVMJAfSRP7N6BpzqI=
github.com/viant/sqlparser v0.7.1-0.20240805161001-5b3b5b7479ae/go.mod h1:2QRGiGZYk2/pjhORGG1zLVQ9JO+bXFhqIVi31mkCRPg=
github.com/viant/sqlparser v0.7.1 h1:YUBsIOUnY8WaF4sdKDz6MqA1+sP5q5QuewE465W2LAM=
github.com/viant/sqlparser v0.7.1/go.mod h1:2QRGiGZYk2/pjhORGG1zLVQ9JO+bXFhqIVi31mkCRPg=
github.com/viant/sqlx v0.15.1 h1:JgZPTfFZEfV6ocnkGqhiHA8R620UBPQopUOfR+tTYMk=
github.com/viant/sqlx v0.15.1/go.mod h1:9IPs8WgNP/jwMbxcDlhYPpSPJkGdqGwCFDWXFNJJQHo=
github.com/viant/structology v0.5.6-0.20240724183243-379c7ed6e097 h1:G/dMlvkw9MQJQ777iBWf/lWFW4793aTLbvyvlMfVUQY=
github.com/viant/structology v0.5.6-0.20240724183243-379c7ed6e097/go.mod h1:63XfkzUyNw7wdi99HJIsH2Rg3d5AOumqbWLUYytOkxU=
github.com/viant/structology v0.5.6-0.20240802174922-5eb157550455 h1:RDd4v38uCo4Gb+3UmQET8/lusddSsLgYuiHZGk5pTTg=
github.com/viant/structology v0.5.6-0.20240802174922-5eb157550455/go.mod h1:63XfkzUyNw7wdi99HJIsH2Rg3d5AOumqbWLUYytOkxU=
github.com/viant/structql v0.4.2-0.20240712002135-b1ef22dd834f h1:B9+Qhjh0Owb2SzNwrRBYSGvAp1kNRDgZoVKPXmcsKP0=
Expand All @@ -1151,14 +1135,10 @@ github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85 h1:zKk+6hqUipkJXCPCH
github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85/go.mod h1:Q/UXviI2Nli8WROEpYd/BELMCSvnulQeyNrbPmMiS/Y=
github.com/viant/x v0.3.0 h1:/3A0z/uySGxMo6ixH90VAcdjI00w5e3REC1zg5hzhJA=
github.com/viant/x v0.3.0/go.mod h1:54jP3qV+nnQdNDaWxEwGTAAzCu9sx9er9htiwTW/Mcw=
github.com/viant/xdatly v0.5.3-0.20240807174337-fc7062eff341 h1:se1cQkYXx8JA+x/kuemAwvEQjT/WyhXejq67AFkfGn0=
github.com/viant/xdatly v0.5.3-0.20240807174337-fc7062eff341/go.mod h1:YwNS31k5r1Ldw5s7wmQXUKaalN6BWcfX9qePO/b/ilc=
github.com/viant/xdatly v0.5.4-0.20240808174705-681c88dd32fa h1:ezJDEcPmKM1EW7tJYvZ5NV+ioIsg0+2PzvBHoSfI1og=
github.com/viant/xdatly v0.5.4-0.20240808174705-681c88dd32fa/go.mod h1:YwNS31k5r1Ldw5s7wmQXUKaalN6BWcfX9qePO/b/ilc=
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259 h1:9Yry3PUBDzc4rWacOYvAq/TKrTV0agvMF0gwm2gaoHI=
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259/go.mod h1:fb8YgbVadk8X5ZLz49LWGzWmQlZd7Y/I5wE0ru44bIo=
github.com/viant/xdatly/handler v0.0.0-20240807174337-fc7062eff341 h1:HjrTL5LUwUG+iPTl07Y4k9kdYNzWxHg3/93+ldVOX8A=
github.com/viant/xdatly/handler v0.0.0-20240807174337-fc7062eff341/go.mod h1:bBa479sCB55VymMrXFccluUFkf6oRI77xhtnWIcL8K0=
github.com/viant/xdatly/handler v0.0.0-20240808174705-681c88dd32fa h1:Clv8cnXLuY55QoBeaoIe5pfAbxPw9TyaBMMOlQvvjSU=
github.com/viant/xdatly/handler v0.0.0-20240808174705-681c88dd32fa/go.mod h1:bBa479sCB55VymMrXFccluUFkf6oRI77xhtnWIcL8K0=
github.com/viant/xdatly/types/core v0.0.0-20240109065401-9758ebacb4bb h1:X4emK6TIR6IXiFlQz9wEdCi5RJMG3dg3e8+VLQ2zhnM=
Expand Down
2 changes: 1 addition & 1 deletion internal/inference/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type (
Connector string
InOutput bool
Of string
IsAsync bool
}

ModificationSetting struct {
Expand Down Expand Up @@ -251,6 +250,7 @@ func buildParameter(field *ast.Field, aTag *tags.Tag, types *xreflect.Types, emb
param.When = pTag.When
param.Scope = pTag.Scope
param.With = pTag.With
param.Async = pTag.Async
param.In = &state.Location{Name: pTag.In, Kind: state.Kind(pTag.Kind)}
if pTag.Required {
value := pTag.Required
Expand Down
2 changes: 1 addition & 1 deletion internal/translator/parser/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (s *Declarations) parseShorthands(declaration *Declaration, cursor *parsly.
case "QuerySelector":
declaration.Explicit = false
case "Async":
declaration.IsAsync = true
declaration.Async = true
}
cursor.MatchOne(whitespaceMatcher)
}
Expand Down
1 change: 1 addition & 0 deletions view/state/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type (
When string `json:",omitempty" yaml:"When"`
With string `json:",omitempty" yaml:"With"`
Cacheable *bool `json:",omitempty" yaml:"Cacheable"`
Async bool `json:",omitempty" yaml:"Async"`

isOutputType bool
_timeLayout string
Expand Down
2 changes: 2 additions & 0 deletions view/state/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ func (p *Parameter) buildTag(fieldName string) reflect.StructTag {
Kind: string(p.In.Kind),
In: string(p.In.Name),
When: p.When,
Async: p.Async,
Cachable: p.Cacheable,
Scope: p.Scope,
With: p.With,
ErrorCode: p.ErrorStatusCode,
Expand Down
2 changes: 2 additions & 0 deletions view/state/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ func BuildParameter(field *reflect.StructField, fs *embed.FS, lookupType xreflec
result.In = &Location{Kind: Kind(pTag.Kind), Name: pTag.In}
result.Scope = pTag.Scope
result.When = pTag.When
result.Async = pTag.Async
result.Cacheable = pTag.Cachable
result.With = pTag.With
if pTag.ErrorCode != 0 {
result.ErrorStatusCode = pTag.ErrorCode
Expand Down
15 changes: 13 additions & 2 deletions view/tags/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type Parameter struct {
DataType string `tag:"dataType,omitempty"` //parameter input type
With string `tag:"with,omitempty"` //optional auxiliary type name holding parameters
Required bool `tag:"required,omitempty"`
Cachable bool `tag:"cachable,omitempty"`
Cachable *bool `tag:"cachable,omitempty"`
Async bool `tag:"async,omitempty"`
}

func (t *Tag) updatedParameter(key string, value string) (err error) {
Expand All @@ -34,7 +35,10 @@ func (t *Tag) updatedParameter(key string, value string) (err error) {
case "when":
tag.When = strings.TrimSpace(value)
case "cachable":
tag.Cachable = true
value := strings.TrimSpace(value) == "" || strings.ToLower(strings.TrimSpace(value)) == "true"
tag.Cachable = &value
case "async":
tag.Async = true
case "scope":
tag.Scope = strings.TrimSpace(value)
case "errorcode":
Expand All @@ -59,6 +63,13 @@ func (p *Parameter) Tag() *tags.Tag {
appendNonEmpty(builder, "kind", p.Kind)
appendNonEmpty(builder, "in", p.In)
appendNonEmpty(builder, "when", p.When)
if p.Cachable != nil {
value := "false"
if *p.Cachable {
value = "true"
}
appendNonEmpty(builder, "cachable", value)
}
appendNonEmpty(builder, "with", p.With)
appendNonEmpty(builder, "scope", p.Scope)
appendNonEmpty(builder, "dataType", p.DataType)
Expand Down

0 comments on commit f85cf14

Please sign in to comment.