github.com/timstclair/heapster@v0.20.0-alpha1/common/influxdb/dummy_influxdb.go (about)

     1  // Copyright 2015 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package influxdb
    16  
    17  import (
    18  	"time"
    19  
    20  	influxdb "github.com/influxdb/influxdb/client"
    21  )
    22  
    23  type PointSavedToInfluxdb struct {
    24  	Ponit influxdb.Point
    25  }
    26  
    27  type FakeInfluxDBClient struct {
    28  	Pnts []PointSavedToInfluxdb
    29  }
    30  
    31  func NewFakeInfluxDBClient() *FakeInfluxDBClient {
    32  	return &FakeInfluxDBClient{[]PointSavedToInfluxdb{}}
    33  }
    34  
    35  func (client *FakeInfluxDBClient) Write(bps influxdb.BatchPoints) (*influxdb.Response, error) {
    36  	for _, pnt := range bps.Points {
    37  		client.Pnts = append(client.Pnts, PointSavedToInfluxdb{pnt})
    38  	}
    39  	return nil, nil
    40  }
    41  
    42  func (client *FakeInfluxDBClient) Query(influxdb.Query) (*influxdb.Response, error) {
    43  	return nil, nil
    44  }
    45  
    46  func (client *FakeInfluxDBClient) Ping() (time.Duration, string, error) {
    47  	return 0, "", nil
    48  }
    49  
    50  var Client = NewFakeInfluxDBClient()
    51  
    52  var Config = InfluxdbConfig{
    53  	User:     "root",
    54  	Password: "root",
    55  	Host:     "localhost:8086",
    56  	DbName:   "k8s",
    57  	Secure:   false,
    58  }