Add ttl option to dynamic query.

This commit is contained in:
Jim Myers 2020-06-24 17:12:05 -04:00
parent 0fc6ade7c4
commit b7e5d49a42
2 changed files with 8 additions and 4 deletions

View File

@ -133,7 +133,7 @@ func TestClient_IntersectMembersToSegment(t *testing.T) {
func TestClient_ExecuteDynamicQuery(t *testing.T) {
client := getClient(t)
resp, err := client.ExecuteDynamicQuery(makeQuery(makeCondition()), false)
resp, err := client.ExecuteDynamicQuery(makeQuery(makeCondition()), false, 10)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@ -149,7 +149,7 @@ func TestClient_ExecuteDynamicQuery(t *testing.T) {
func TestClient_ExecuteDynamicQueryWithWindowing(t *testing.T) {
client := getClient(t)
resp, err := client.ExecuteDynamicQuery(makeWindowingQuery(), false)
resp, err := client.ExecuteDynamicQuery(makeWindowingQuery(), false, 10)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@ -170,7 +170,7 @@ func TestClient_ExecuteDynamicQueryWithError(t *testing.T) {
client := getClient(t)
query := makeQuery(makeCondition())
query.Table = "foobar"
resp, err := client.ExecuteDynamicQuery(query, false)
resp, err := client.ExecuteDynamicQuery(query, false, 10)
if err != nil {
t.Fatalf("Unexpected error: %v", err)

View File

@ -11,14 +11,18 @@ type ExecuteDynamicQueryResponse struct {
Results []interface{} `mapstructure:"results" json:"results"`
ResultCount int `mapstructure:"result_count" json:"result_count"`
CompiledSQL string `mapstructure:"compiled_sql" json:"compiled_sql,omitempty"`
TTLHash string `mapstructure:"ttl_hash" json:"ttl_hash,omitempty"`
TTLStart string `mapstructure:"ttl_start" json:"ttl_start,omitempty"`
TTLExpiry string `mapstructure:"ttl_expiry" json:"ttl_expiry,omitempty"`
Error string `mapstructure:"error,omitempty" json:"error,omitempty"`
}
// ExecuteDynamicQuery returns the query results
func (c Client) ExecuteDynamicQuery(query dynamicquery.Query, debug bool) (*ExecuteDynamicQueryResponse, error) {
func (c Client) ExecuteDynamicQuery(query dynamicquery.Query, debug bool, ttlSeconds int) (*ExecuteDynamicQueryResponse, error) {
var input = make(map[string]interface{})
input["query"] = query
input["debug"] = debug
input["ttl_seconds"] = ttlSeconds
var response ExecuteDynamicQueryResponse