github.com/caesarxuchao/heapster@v1.1.0/events/core/types.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 core
    16  
    17  import (
    18  	"time"
    19  
    20  	kube_api "k8s.io/kubernetes/pkg/api"
    21  )
    22  
    23  type EventBatch struct {
    24  	// When this batch was created.
    25  	Timestamp time.Time
    26  	// List of events included in the batch.
    27  	Events []*kube_api.Event
    28  }
    29  
    30  // A place from where the events should be scraped.
    31  type EventSource interface {
    32  	// This is a mutable method. Each call to this method clears the internal buffer so that
    33  	// each event can be obtained only once.
    34  	GetNewEvents() *EventBatch
    35  }
    36  
    37  type EventSink interface {
    38  	Name() string
    39  
    40  	// Exports data to the external storge. The funciton should be synchronous/blocking and finish only
    41  	// after the given EventBatch was written. This will allow sink manager to push data only to these
    42  	// sinks that finished writing the previous data.
    43  	ExportEvents(*EventBatch)
    44  	// Stops the sink at earliest convenience.
    45  	Stop()
    46  }