[ 
https://issues.apache.org/jira/browse/AURORA-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ezequiel Torres updated AURORA-1991:
------------------------------------
    Description: 
h1. *+What?+*

Struct 
[TaskQuery|https://git-wip-us.apache.org/repos/asf?p=aurora.git;a=blob;f=api/src/main/thrift/org/apache/aurora/gen/api.thrift;h=7265b11103aa12743c42355163ae64e98e965d7f;hb=HEAD#l579]
 should have optional parameters in order to be able to be used in languages 
like Go where types does not have a null value by default.

The following is the autogenerated code created by Thrift with optional 
parameters and without optional parameters in Golang:

+*_Without Optional Parameters_*+
{code}
type TaskQuery struct {
  // unused field # 1
  JobName string `thrift:"jobName,2" json:"jobName"`
  // unused field # 3
  TaskIds map[string]bool `thrift:"taskIds,4" json:"taskIds"`
  Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
  // unused field # 6
  InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
  // unused field # 8
  Environment string `thrift:"environment,9" json:"environment"`
  SlaveHosts map[string]bool `thrift:"slaveHosts,10" json:"slaveHosts"`
  JobKeys map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
  Offset int32 `thrift:"offset,12" json:"offset"`
  Limit int32 `thrift:"limit,13" json:"limit"`
  Role string `thrift:"role,14" json:"role"`
}
{code}
_*+With Optional Parameters+*_
{code}
type TaskQuery struct {
        // unused field # 1
        JobName *string `thrift:"jobName,2" json:"jobName"`
        // unused field # 3
        TaskIds  map[string]bool         `thrift:"taskIds,4" json:"taskIds"`
        Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
        // unused field # 6
        InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
        // unused field # 8
        Environment *string          `thrift:"environment,9" json:"environment"`
        SlaveHosts  map[string]bool  `thrift:"slaveHosts,10" json:"slaveHosts"`
        JobKeys     map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
        Offset      *int32           `thrift:"offset,12" json:"offset"`
        Limit       *int32           `thrift:"limit,13" json:"limit"`
        Role        *string          `thrift:"role,14" json:"role"`
}
{code}
It can be seen that with an optional parameters like JobName, Role and 
Environment now can be set with a null value
h1. *+Why?+*

With the current structure of the TaskQuery object, it is not possible to make 
queries without explicitly setting all the fields of the TaskQuery object in 
Golang. Moreover, the lack of a null value in the structure of the TaskQuery 
object limits the type of queries that can be obtained from the Aurora Thrift 
API in Golang since a parameter cannot be skipped.

To illustrate the problem, a small code snippet using 
[gorealis|https://github.com/paypal/gorealis] is shown: 
{code:go}
func main() {
    cluster := realis.GetDefaultClusterFromZKUrl("192.168.255.31:2181")
    leader, err := realis.LeaderFromZK(*cluster)

    clientOptions := []realis.ClientOption{
        realis.ThriftJSON(),
        realis.SchedulerUrl(leader),
    }
    client, err := realis.NewRealisClient(clientOptions...)
    if err != nil {
        fmt.Println(err)
        return
    }

        if err !=  nil {
                fmt.Printf("Error: %s\n", err)
        return
        }
        fmt.Printf("Leader: %s\n", leader)
    tasks, err := client.GetTaskStatus(&aurora.TaskQuery{})
{code}


 

 

  was:
h1. What?
Struct 
[TaskQuery|https://git-wip-us.apache.org/repos/asf?p=aurora.git;a=blob;f=api/src/main/thrift/org/apache/aurora/gen/api.thrift;h=7265b11103aa12743c42355163ae64e98e965d7f;hb=HEAD#l579]
 should have optional parameters in order to be able to be used in languages 
like Go where types does not have a null value by default.

The following is the autogenerated code created by Thrift with optional 
parameters and without optional parameters in Golang:

+*_Without Optional Parameters_*+
{code:go}
type TaskQuery struct {
  // unused field # 1
  JobName string `thrift:"jobName,2" json:"jobName"`
  // unused field # 3
  TaskIds map[string]bool `thrift:"taskIds,4" json:"taskIds"`
  Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
  // unused field # 6
  InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
  // unused field # 8
  Environment string `thrift:"environment,9" json:"environment"`
  SlaveHosts map[string]bool `thrift:"slaveHosts,10" json:"slaveHosts"`
  JobKeys map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
  Offset int32 `thrift:"offset,12" json:"offset"`
  Limit int32 `thrift:"limit,13" json:"limit"`
  Role string `thrift:"role,14" json:"role"`
}
{code}

_*+With Optional Parameters+*_
{code:go}

type TaskQuery struct {
        // unused field # 1
        JobName *string `thrift:"jobName,2" json:"jobName"`
        // unused field # 3
        TaskIds  map[string]bool         `thrift:"taskIds,4" json:"taskIds"`
        Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
        // unused field # 6
        InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
        // unused field # 8
        Environment *string          `thrift:"environment,9" json:"environment"`
        SlaveHosts  map[string]bool  `thrift:"slaveHosts,10" json:"slaveHosts"`
        JobKeys     map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
        Offset      *int32           `thrift:"offset,12" json:"offset"`
        Limit       *int32           `thrift:"limit,13" json:"limit"`
        Role        *string          `thrift:"role,14" json:"role"`
}
{code}

It can be seen that with an optional parameters like JobName, Role and 
Environment now can be set with a null value

h1. Why?
With the current structure of the TaskQuery object, it is not possible to make 
queries without explicitly setting all the fields of the TaskQuery object in 
Golang. Moreover, the lack of a null value in the structure of the TaskQuery 
object limits the type of queries that can be obtained from the Aurora Thrift 
API in Golang since a parameter cannot be skipped.




> TaskEvents in API Thrift should have optional parameters
> --------------------------------------------------------
>
>                 Key: AURORA-1991
>                 URL: https://issues.apache.org/jira/browse/AURORA-1991
>             Project: Aurora
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: 0.19.1
>            Reporter: Ezequiel Torres
>            Priority: Minor
>
> h1. *+What?+*
> Struct 
> [TaskQuery|https://git-wip-us.apache.org/repos/asf?p=aurora.git;a=blob;f=api/src/main/thrift/org/apache/aurora/gen/api.thrift;h=7265b11103aa12743c42355163ae64e98e965d7f;hb=HEAD#l579]
>  should have optional parameters in order to be able to be used in languages 
> like Go where types does not have a null value by default.
> The following is the autogenerated code created by Thrift with optional 
> parameters and without optional parameters in Golang:
> +*_Without Optional Parameters_*+
> {code}
> type TaskQuery struct {
>   // unused field # 1
>   JobName string `thrift:"jobName,2" json:"jobName"`
>   // unused field # 3
>   TaskIds map[string]bool `thrift:"taskIds,4" json:"taskIds"`
>   Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
>   // unused field # 6
>   InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
>   // unused field # 8
>   Environment string `thrift:"environment,9" json:"environment"`
>   SlaveHosts map[string]bool `thrift:"slaveHosts,10" json:"slaveHosts"`
>   JobKeys map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
>   Offset int32 `thrift:"offset,12" json:"offset"`
>   Limit int32 `thrift:"limit,13" json:"limit"`
>   Role string `thrift:"role,14" json:"role"`
> }
> {code}
> _*+With Optional Parameters+*_
> {code}
> type TaskQuery struct {
>       // unused field # 1
>       JobName *string `thrift:"jobName,2" json:"jobName"`
>       // unused field # 3
>       TaskIds  map[string]bool         `thrift:"taskIds,4" json:"taskIds"`
>       Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"`
>       // unused field # 6
>       InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"`
>       // unused field # 8
>       Environment *string          `thrift:"environment,9" json:"environment"`
>       SlaveHosts  map[string]bool  `thrift:"slaveHosts,10" json:"slaveHosts"`
>       JobKeys     map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"`
>       Offset      *int32           `thrift:"offset,12" json:"offset"`
>       Limit       *int32           `thrift:"limit,13" json:"limit"`
>       Role        *string          `thrift:"role,14" json:"role"`
> }
> {code}
> It can be seen that with an optional parameters like JobName, Role and 
> Environment now can be set with a null value
> h1. *+Why?+*
> With the current structure of the TaskQuery object, it is not possible to 
> make queries without explicitly setting all the fields of the TaskQuery 
> object in Golang. Moreover, the lack of a null value in the structure of the 
> TaskQuery object limits the type of queries that can be obtained from the 
> Aurora Thrift API in Golang since a parameter cannot be skipped.
> To illustrate the problem, a small code snippet using 
> [gorealis|https://github.com/paypal/gorealis] is shown: 
> {code:go}
> func main() {
>     cluster := realis.GetDefaultClusterFromZKUrl("192.168.255.31:2181")
>     leader, err := realis.LeaderFromZK(*cluster)
>     clientOptions := []realis.ClientOption{
>         realis.ThriftJSON(),
>         realis.SchedulerUrl(leader),
>     }
>     client, err := realis.NewRealisClient(clientOptions...)
>     if err != nil {
>         fmt.Println(err)
>       return
>     }
>       if err !=  nil {
>               fmt.Printf("Error: %s\n", err)
>         return
>       }
>       fmt.Printf("Leader: %s\n", leader)
>     tasks, err := client.GetTaskStatus(&aurora.TaskQuery{})
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to