Beispiel #1
0
func newProperties(r *http.Request) (*queue.Properties, error) {
	props := queue.NewProperties()
	if s := r.URL.Query().Get("retry"); s != "" {
		n, err := types.ParseRetry(s)
		if err != nil {
			return nil, err
		}
		props.SetRetry(n)
	}

	if s := r.URL.Query().Get("timeout"); s != "" {
		d, err := types.ParseDuration(s)
		if err != nil {
			return nil, err
		}
		props.SetTimeout(d)
	}

	if s := r.URL.Query().Get("accum_time"); s != "" {
		d, err := types.ParseDuration(s)
		if err != nil {
			return nil, err
		}
		props.SetAccumTime(d)
	}

	return props, nil
}
Beispiel #2
0
func setProperties(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	name := queueName(ctx)
	q := queue.FromContext(ctx)
	b, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return err
	}
	props := queue.NewProperties()
	if err := json.Unmarshal(b, props); err != nil {
		return err
	}
	q.SetProperties(name, props)
	return nil
}