proxystore

package
v0.0.0-...-c7476d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Overview

Example
s := New()

endpoint := func(ip string, ready bool) *globalv1.EndpointInfo {
	return &globalv1.EndpointInfo{
		Namespace:   "default",
		SourceName:  "svc0",
		ServiceName: "svc0",
		Conditions: &globalv1.EndpointConditions{
			Ready: ready,
		},
		Endpoint: &localv1.Endpoint{
			IPs: &localv1.IPSet{V4: []string{ip}},
		},
	}
}

for _, twoReady := range []bool{true, false} {
	s.Update(func(tx *Tx) {
		tx.SetService(&localv1.Service{
			Namespace: "default",
			Name:      "svc0",
		})

		tx.SetEndpointsOfSource("default", "svc0", []*globalv1.EndpointInfo{
			endpoint("10.0.0.1", false),
			endpoint("10.0.0.2", twoReady),
		})
	})

	fmt.Println("two ready:", twoReady)
	infos := make([]*globalv1.EndpointInfo, 0)
	s.View(0, func(tx *Tx) {
		tx.EachEndpointOfService("default", "svc0", func(info *globalv1.EndpointInfo) {
			infos = append(infos, info)
		})
	})

	sort.Slice(infos, func(i, j int) bool { return infos[i].Endpoint.String() < infos[j].Endpoint.String() })

	for _, info := range infos {
		fmt.Println("-", info.Endpoint, "[", info.Conditions, "]")
	}
}
Output:

two ready: true
- IPs:{V4:"10.0.0.1"} [  ]
- IPs:{V4:"10.0.0.2"} [ Ready:true ]
two ready: false
- IPs:{V4:"10.0.0.1"} [  ]
- IPs:{V4:"10.0.0.2"} [  ]

Index

Examples

Constants

Variables

View Source
var AllSets = []Set{Services, Endpoints, Nodes}

Functions

This section is empty.

Types

type Hashed

type Hashed interface {
	GetHash() uint64
}

type KV

type KV struct {
	Sync      *bool
	Set       Set
	Namespace string
	Name      string
	Source    string
	Key       string

	Value Hashed

	Service  *globalv1.ServiceInfo
	Endpoint *globalv1.EndpointInfo
	Node     *globalv1.NodeInfo
}

func (*KV) Less

func (a *KV) Less(i btree.Item) bool

func (*KV) Path

func (a *KV) Path() string

func (*KV) SetPath

func (a *KV) SetPath(path string)

type Set

type Set = localv1.Set

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New() *Store

func (*Store) Close

func (s *Store) Close()

func (*Store) Update

func (s *Store) Update(update func(tx *Tx))

func (*Store) View

func (s *Store) View(afterRev uint64, view func(tx *Tx)) (rev uint64, closed bool)

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) AllSynced

func (tx *Tx) AllSynced() bool

sync funcs

func (*Tx) DelEndpointsOfSource

func (tx *Tx) DelEndpointsOfSource(namespace, sourceName string)

func (*Tx) DelNode

func (tx *Tx) DelNode(name string)

func (*Tx) DelRaw

func (tx *Tx) DelRaw(set Set, path string)

func (*Tx) DelService

func (tx *Tx) DelService(namespace, name string)

func (*Tx) Each

func (tx *Tx) Each(set Set, callback func(*KV) bool)

Each iterate over each item in the given set, stopping if the callback returns false

func (*Tx) EachEndpointOfService

func (tx *Tx) EachEndpointOfService(namespace, serviceName string, callback func(*globalv1.EndpointInfo))

func (*Tx) GetNode

func (tx *Tx) GetNode(name string) *globalv1.Node

func (*Tx) IsSynced

func (tx *Tx) IsSynced(set Set) bool

func (*Tx) Reset

func (tx *Tx) Reset()

Reset clears the store data

func (*Tx) SetEndpoint

func (tx *Tx) SetEndpoint(ei *globalv1.EndpointInfo)

func (*Tx) SetEndpointsOfSource

func (tx *Tx) SetEndpointsOfSource(namespace, sourceName string, eis []*globalv1.EndpointInfo)

SetEndpointsOfSource replaces ALL endpoints of a single source (add new, update existing, delete removed)

func (*Tx) SetNode

func (tx *Tx) SetNode(n *globalv1.Node)

func (*Tx) SetRaw

func (tx *Tx) SetRaw(set Set, path string, value Hashed)

func (*Tx) SetService

func (tx *Tx) SetService(s *localv1.Service)

func (*Tx) SetSync

func (tx *Tx) SetSync(set Set)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL