github.com/rudderlabs/rudder-go-kit@v0.30.0/config/valueloader.go (about)

     1  package config
     2  
     3  // SingleValueLoader returns a ValueLoader that always returns the same value.
     4  func SingleValueLoader[T any](v T) ValueLoader[T] {
     5  	return &loader[T]{v}
     6  }
     7  
     8  // ValueLoader is an interface that can be used to load a value.
     9  type ValueLoader[T any] interface {
    10  	Load() T
    11  }
    12  
    13  // loader is a ValueLoader that always returns the same value.
    14  type loader[T any] struct {
    15  	v T
    16  }
    17  
    18  // Load returns the value.
    19  func (l *loader[T]) Load() T {
    20  	return l.v
    21  }