Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 8 of 8 for NewStatic (0.87 sec)

  1. pkg/kube/krt/join_test.go

    	"istio.io/istio/pkg/kube/krt"
    	"istio.io/istio/pkg/slices"
    	"istio.io/istio/pkg/test"
    	"istio.io/istio/pkg/test/util/assert"
    )
    
    func TestJoinCollection(t *testing.T) {
    	c1 := krt.NewStatic[Named](nil)
    	c2 := krt.NewStatic[Named](nil)
    	c3 := krt.NewStatic[Named](nil)
    	j := krt.JoinCollection([]krt.Collection[Named]{c1.AsCollection(), c2.AsCollection(), c3.AsCollection()})
    	last := atomic.NewString("")
    	j.Register(func(o krt.Event[Named]) {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Tue Apr 09 19:55:53 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  2. pkg/kube/krt/recomputetrigger_test.go

    import (
    	"testing"
    
    	"istio.io/istio/pkg/kube/krt"
    	"istio.io/istio/pkg/ptr"
    	"istio.io/istio/pkg/test/util/assert"
    )
    
    func TestRecomputeTrigger(t *testing.T) {
    	rt := krt.NewRecomputeTrigger()
    	col1 := krt.NewStatic(ptr.Of("foo")).AsCollection()
    	response := "foo"
    	col2 := krt.NewCollection(col1, func(ctx krt.HandlerContext, i string) *string {
    		rt.MarkDependant(ctx)
    		return ptr.Of(response)
    	})
    	tt := assert.NewTracker[string](t)
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Feb 07 05:51:56 UTC 2024
    - 1.3K bytes
    - Viewed (0)
  3. pkg/kube/krt/singleton.go

    type dummyValue struct{}
    
    func (d dummyValue) ResourceName() string {
    	return ""
    }
    
    type StaticSingleton[T any] interface {
    	Singleton[T]
    	Set(*T)
    }
    
    func NewStatic[T any](initial *T) StaticSingleton[T] {
    	val := new(atomic.Pointer[T])
    	val.Store(initial)
    	x := &static[T]{
    		val:           val,
    		id:            nextUID(),
    		eventHandlers: &handlers[T]{},
    	}
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Fri May 10 23:33:56 UTC 2024
    - 4.2K bytes
    - Viewed (0)
  4. pkg/kube/krt/recomputetrigger.go

    	// is called to ensure our event is not suppressed.
    	i *atomic.Int32
    }
    
    func NewRecomputeTrigger() *RecomputeTrigger {
    	inner := NewStatic[int32](ptr.Of(int32(0)))
    	return &RecomputeTrigger{inner: inner, i: atomic.NewInt32(0)}
    }
    
    // TriggerRecomputation tells all dependants to recompute
    func (r *RecomputeTrigger) TriggerRecomputation() {
    	v := r.i.Inc()
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Feb 07 05:51:56 UTC 2024
    - 2K bytes
    - Viewed (0)
  5. pkg/kube/krt/krttest/helpers.go

    }
    
    func GetMockSingleton[T any](mc *MockCollection) krt.StaticSingleton[T] {
    	t := extractType[T](&mc.inputs)
    	if len(t) > 1 {
    		mc.t.Helper()
    		mc.t.Fatalf("multiple types returned")
    	}
    	return krt.NewStatic(slices.First(t))
    }
    
    func extractType[T any](items *[]any) []T {
    	var matched []T
    	var unmatched []any
    	arr := *items
    	for _, val := range arr {
    		if c, ok := val.(T); ok {
    			matched = append(matched, c)
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Tue May 21 19:33:01 UTC 2024
    - 2.1K bytes
    - Viewed (0)
  6. pkg/kube/krt/singleton_test.go

    			Namespace: "ns",
    		},
    	})
    	tt.WaitUnordered("delete/", "add/ns/a")
    	assert.Equal(t, *ConfigMapNames.Get(), "ns/a")
    }
    
    func TestNewStatic(t *testing.T) {
    	tt := assert.NewTracker[string](t)
    	s := krt.NewStatic[string](nil)
    	s.Register(TrackerHandler[string](tt))
    
    	assert.Equal(t, s.Get(), nil)
    
    	s.Set(ptr.Of("foo"))
    	assert.Equal(t, s.Get(), ptr.Of("foo"))
    	tt.WaitOrdered("add/foo")
    
    	s.Set(nil)
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Thu Apr 11 08:27:29 UTC 2024
    - 2.9K bytes
    - Viewed (0)
  7. pkg/kube/krt/README.md

    This is basically an `Informer`, but not tied to Kubernetes.
    
    Currently, there are three ways to build a `Collection`:
    * Built from an `Informer` with `WrapClient` or `NewInformer`.
    * Statically configured with `NewStatic`.
    * Derived from other collections (more information on this below).
    
    Unlike `Informers`, these primitives work on arbitrary objects.
    However, these objects are expected to have some properties, depending on their usage.
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Mon Dec 18 17:21:50 UTC 2023
    - 11.8K bytes
    - Viewed (0)
  8. pilot/pkg/serviceregistry/kube/controller/ambient/workloads_test.go

    func GetMeshConfig(mc *krttest.MockCollection) krt.StaticSingleton[MeshConfig] {
    	attempt := krttest.GetMockSingleton[MeshConfig](mc)
    	if attempt.Get() == nil {
    		return krt.NewStatic(&MeshConfig{mesh.DefaultMeshConfig()})
    	}
    	return attempt
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Thu Jun 13 16:51:29 UTC 2024
    - 20.3K bytes
    - Viewed (0)
Back to top