mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 08:13:28 +03:00
api: Implement bucket notification. (#2271)
* Implement basic S3 notifications through queues Supports multiple queues and three basic queue types: 1. NilQueue -- messages don't get sent anywhere 2. LogQueue -- messages get logged 3. AmqpQueue -- messages are sent to an AMQP queue * api: Implement bucket notification. Supports two different queue types - AMQP - ElasticSearch. * Add support for redis
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
f85d94288d
commit
f248089523
+74
@@ -0,0 +1,74 @@
|
||||
// Copyright 2012-2015 Oliver Eilhard. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-license.
|
||||
// See http://olivere.mit-license.org/license.txt for details.
|
||||
|
||||
package elastic
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FetchSourceContext struct {
|
||||
fetchSource bool
|
||||
transformSource bool
|
||||
includes []string
|
||||
excludes []string
|
||||
}
|
||||
|
||||
func NewFetchSourceContext(fetchSource bool) *FetchSourceContext {
|
||||
return &FetchSourceContext{
|
||||
fetchSource: fetchSource,
|
||||
includes: make([]string, 0),
|
||||
excludes: make([]string, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) FetchSource() bool {
|
||||
return fsc.fetchSource
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) SetFetchSource(fetchSource bool) {
|
||||
fsc.fetchSource = fetchSource
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) Include(includes ...string) *FetchSourceContext {
|
||||
fsc.includes = append(fsc.includes, includes...)
|
||||
return fsc
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) Exclude(excludes ...string) *FetchSourceContext {
|
||||
fsc.excludes = append(fsc.excludes, excludes...)
|
||||
return fsc
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) TransformSource(transformSource bool) *FetchSourceContext {
|
||||
fsc.transformSource = transformSource
|
||||
return fsc
|
||||
}
|
||||
|
||||
func (fsc *FetchSourceContext) Source() (interface{}, error) {
|
||||
if !fsc.fetchSource {
|
||||
return false, nil
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"includes": fsc.includes,
|
||||
"excludes": fsc.excludes,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Query returns the parameters in a form suitable for a URL query string.
|
||||
func (fsc *FetchSourceContext) Query() url.Values {
|
||||
params := url.Values{}
|
||||
if !fsc.fetchSource {
|
||||
params.Add("_source", "false")
|
||||
return params
|
||||
}
|
||||
if len(fsc.includes) > 0 {
|
||||
params.Add("_source_include", strings.Join(fsc.includes, ","))
|
||||
}
|
||||
if len(fsc.excludes) > 0 {
|
||||
params.Add("_source_exclude", strings.Join(fsc.excludes, ","))
|
||||
}
|
||||
return params
|
||||
}
|
||||
Reference in New Issue
Block a user