diff --git a/api/index_handler.go b/api/index_handler.go index 903d5d7..b6aa785 100755 --- a/api/index_handler.go +++ b/api/index_handler.go @@ -105,9 +105,7 @@ func (handler *API) handleRead(w http.ResponseWriter, req *http.Request, body [] var hash string if handler.cacheConfig.CacheEnabled { - hash = getHash(handler.cacheConfig.KeyPrefix, req, body) - cache, err := handler.cacheHandler.Get(hash) if len(cache) > 0 && err == nil { if global.Env().IsDebug { diff --git a/api/init.go b/api/init.go index d032652..c175fad 100755 --- a/api/init.go +++ b/api/init.go @@ -20,15 +20,16 @@ type CacheHandler struct { config *CacheConfig client *redis.Client } +var client *redis.Client func (handler CacheHandler) Init() { - client := redis.NewClient(&redis.Options{ + client = redis.NewClient(&redis.Options{ Addr: fmt.Sprintf("%s:%s", handler.config.RedisConfig.Host, handler.config.RedisConfig.Port), Password: handler.config.RedisConfig.Password, DB: handler.config.RedisConfig.DB, }) - + handler.client=client _, err := client.Ping().Result() if err != nil { log.Error("cache server is not ready: ", err) @@ -37,11 +38,13 @@ func (handler CacheHandler) Init() { } func (handler CacheHandler) Get(key string) ([]byte, error) { - return nil, nil + data,err:= client.Get(key).Bytes() + return data,err } -func (handler CacheHandler) Set(string, []byte, int64) (bool, error) { - return false, nil +func (handler CacheHandler) Set(key string,data []byte,ttl int64) (bool, error) { + err:=client.Set(key,data, time.Duration(ttl)*time.Millisecond).Err() + return err==nil,err } type RedisConfig struct { diff --git a/modules/floating_ip/floating_ip.go b/modules/floating_ip/floating_ip.go index 6d17722..fdbdbee 100644 --- a/modules/floating_ip/floating_ip.go +++ b/modules/floating_ip/floating_ip.go @@ -18,7 +18,6 @@ package floating_ip import ( log "github.com/cihub/seelog" - "infini.sh/framework/core/api" "infini.sh/framework/core/config" "infini.sh/framework/core/env" "infini.sh/framework/core/net" @@ -58,7 +57,7 @@ func (module FloatingIPPlugin) Start() error { panic(err) } - apiConfig := &api.APIConfig{} + apiConfig := &config.APIConfig{} env.ParseConfig("api", apiConfig) log.Infof("high availability address: %s://%s:%s", apiConfig.GetSchema(), floatingIPConfig.IP, apiConfig.NetworkConfig.GetBindingPort()) return nil diff --git a/proxy.yml b/proxy.yml index 0450d98..7e59f2e 100755 --- a/proxy.yml +++ b/proxy.yml @@ -7,7 +7,7 @@ api: network: binding: 0.0.0.0:2900 tls: - enabled: true + enabled: false elasticsearch: - name: default @@ -32,8 +32,7 @@ cache: plugins: - name: proxy enabled: true - ui_enabled: false - pass_through: ["_update","_search", "_count", "_analyze", "_mget", "_doc", "_mtermvectors", "_msearch", "_search_shards", "_suggest", "_validate", "_explain", "_field_caps", "_rank_eval", "_aliases"] + pass_through: [] upstream: - name: primary enabled: true @@ -45,16 +44,9 @@ plugins: max_queue_depth: -1 timeout: 60s elasticsearch: default - - name: backup - enabled: false - cache_enabled: false - queue_name: backup - max_queue_depth: -1 - timeout: 60s - elasticsearch: default - name: floating_ip - enabled: true + enabled: false ip: 192.168.1.222 netmask: 255.255.255.0 interface: en0 @@ -69,14 +61,6 @@ pipelines: error: joint: logging enabled: true -- name: backup - start: - joint: index - enabled: true - process: [] - error: - joint: logging - enabled: true modules: @@ -87,13 +71,6 @@ modules: store_enabled: true orm_enabled: true -- name: web - enabled: false - tls: - enabled: true - network: - binding: 127.0.0.1:9000 - - name: pipeline enabled: true runners: @@ -104,11 +81,3 @@ modules: threshold_in_ms: 0 timeout_in_ms: 5000 pipeline_id: primary - - - name: backup - enabled: true - input_queue: backup - max_go_routine: 1 - threshold_in_ms: 0 - timeout_in_ms: 5000 - pipeline_id: backup