github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/pkg/cache/types/types.go (about)

     1  package types
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/golang/protobuf/proto"
     7  )
     8  
     9  // Resource is the base interface for the xDS payload.
    10  type Resource interface {
    11  	proto.Message
    12  }
    13  
    14  // ResourceWithTTL is a Resource with an optional TTL.
    15  type ResourceWithTTL struct {
    16  	Resource Resource
    17  	TTL      *time.Duration
    18  }
    19  
    20  // MarshaledResource is an alias for the serialized binary array.
    21  type MarshaledResource = []byte
    22  
    23  // SkipFetchError is the error returned when the cache fetch is short
    24  // circuited due to the client's version already being up-to-date.
    25  type SkipFetchError struct{}
    26  
    27  // Error satisfies the error interface
    28  func (e SkipFetchError) Error() string {
    29  	return "skip fetch: version up to date"
    30  }
    31  
    32  // ResponseType enumeration of supported response types
    33  type ResponseType int
    34  
    35  const (
    36  	Endpoint ResponseType = iota
    37  	Cluster
    38  	Route
    39  	Listener
    40  	Secret
    41  	Runtime
    42  	ExtensionConfig
    43  	UnknownType // token to count the total number of supported types
    44  )