director

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvertiseOSDF

func AdvertiseOSDF() error

Populate internal cache with origin/cache ads

func ConfigTTLCache added in v1.0.4

func ConfigTTLCache(ctx context.Context, wg *sync.WaitGroup)

Configure TTL caches to enable cache eviction and other additional cache events handling logic

The `ctx` is the context for listening to server shutdown event in order to cleanup internal cache eviction goroutine and `wg` is the wait group to notify when the clean up goroutine finishes

func CreateAdvertiseToken

func CreateAdvertiseToken(namespace string) (string, error)

func CreateDirectorSDToken added in v1.0.4

func CreateDirectorSDToken() (string, error)

Create a token for director's Prometheus instance to access director's origins service discovery endpoint. This function is intended to be called only on a director server

func CreateDirectorScrapeToken added in v1.0.4

func CreateDirectorScrapeToken() (string, error)

Create a token for director's Prometheus scraper to access discovered origins /metrics endpoint. This function is intended to be called on a director server

func CreateDirectorTestReportToken added in v1.0.4

func CreateDirectorTestReportToken(originWebUrl string) (string, error)

Create a token for director to report the health status to the origin

func DiscoverOrigins added in v1.0.4

func DiscoverOrigins(ctx *gin.Context)

Return a list of available origins URL in Prometheus HTTP SD format for director's Prometheus service discovery

func DownloadDB

func DownloadDB(localFile string) error

func GetAdsForPath

func GetAdsForPath(reqPath string) (originNamespace NamespaceAd, originAds []ServerAd, cacheAds []ServerAd)

func GetLatLong

func GetLatLong(addr netip.Addr) (lat float64, long float64, err error)

func GetRegistryIssuerURL added in v1.0.4

func GetRegistryIssuerURL(prefix string) (string, error)

func InitializeDB

func InitializeDB()

func ListNamespaces added in v1.0.4

func ListNamespaces(ctx *gin.Context)

func PeriodicCacheReload

func PeriodicCacheReload()

func PeriodicDirectorTest added in v1.0.4

func PeriodicDirectorTest(ctx context.Context, originAd ServerAd)

Run a periodic test file transfer against an origin to ensure it's talking to the director

func PeriodicMaxMindReload

func PeriodicMaxMindReload()

func RecordAd

func RecordAd(ad ServerAd, namespaceAds *[]NamespaceAd)

func RedirectToCache

func RedirectToCache(ginCtx *gin.Context)

func RedirectToOrigin

func RedirectToOrigin(ginCtx *gin.Context)

func RegisterCache added in v1.0.4

func RegisterCache(ctx *gin.Context)

func RegisterDirector

func RegisterDirector(router *gin.RouterGroup)

func RegisterDirectorAuth added in v1.0.4

func RegisterDirectorAuth(router *gin.RouterGroup)

func RegisterDirectorWebAPI added in v1.0.4

func RegisterDirectorWebAPI(router *gin.RouterGroup)

func RegisterOrigin

func RegisterOrigin(ctx *gin.Context)

func ShortcutMiddleware

func ShortcutMiddleware(defaultResponse string) gin.HandlerFunc

Middleware sends GET /foo/bar to the RedirectToCache function, as if the original request had been made to /api/v1.0/director/object/foo/bar

func UpdateLatLong

func UpdateLatLong(ad *ServerAd) error

func VerifyAdvertiseToken

func VerifyAdvertiseToken(token, namespace string) (bool, error)

Given a token and a location in the namespace to advertise in, see if the entity is authorized to advertise an origin for the namespace

func VerifyDirectorSDToken added in v1.0.4

func VerifyDirectorSDToken(strToken string) (bool, error)

Verify that a token received is a valid token from director and has correct scope for accessing the service discovery endpoint. This function is intended to be called on the same director server that issues the token.

func VerifyDirectorTestReportToken added in v1.0.4

func VerifyDirectorTestReportToken(strToken string) (bool, error)

Verify that a token received is a valid token from director

Types

type DirectorTest added in v1.0.4

type DirectorTest struct {
	Status    string `json:"status"`
	Message   string `json:"message"`
	Timestamp int64  `json:"timestamp"`
}

type DiscoveryResponse added in v1.0.4

type DiscoveryResponse struct {
	Issuer  string `json:"issuer"`
	JwksUri string `json:"jwks_uri"`
}

type NamespaceAd

type NamespaceAd struct {
	RequireToken  bool         `json:"requireToken"`
	Path          string       `json:"path"`
	Issuer        url.URL      `json:"url"`
	MaxScopeDepth uint         `json:"maxScopeDepth"`
	Strategy      StrategyType `json:"strategy"`
	BasePath      string       `json:"basePath"`
	VaultServer   string       `json:"vaultServer"`
	DirlistHost   string       `json:"dirlisthost"`
}

func ListNamespacesFromOrigins added in v1.0.4

func ListNamespacesFromOrigins() []NamespaceAd

List all namespaces from origins registered at the director

type NamespaceCache added in v1.0.4

type NamespaceCache interface {
	Register(u string, options ...jwk.RegisterOption) error
	Get(ctx context.Context, u string) (jwk.Set, error)
}

Create interface Add it to namespacekeys in place of jwk.cache

type OriginAdvertise

type OriginAdvertise struct {
	Name       string        `json:"name"`
	URL        string        `json:"url"`               // This is the url for origin's XRootD service and file transfer
	WebURL     string        `json:"web_url,omitempty"` // This is the url for origin's web engine and APIs
	Namespaces []NamespaceAd `json:"namespaces"`
}

type PromDiscoveryItem added in v1.0.4

type PromDiscoveryItem struct {
	Targets []string          `json:"targets"`
	Labels  map[string]string `json:"labels"`
}

type ServerAd

type ServerAd struct {
	Name      string
	AuthURL   url.URL
	URL       url.URL // This is server's XRootD URL for file transfer
	WebURL    url.URL // This is server's Web interface and API
	Type      ServerType
	Latitude  float64
	Longitude float64
}

func ListServerAds added in v1.0.4

func ListServerAds(serverTypes []ServerType) []ServerAd

List all serverAds in the cache that matches the serverType array

func SortServers

func SortServers(addr netip.Addr, ads []ServerAd) ([]ServerAd, error)

type ServerType

type ServerType string
const (
	CacheType  ServerType = "Cache"
	OriginType ServerType = "Origin"
)

type StrategyType

type StrategyType string
const (
	OAuthStrategy StrategyType = "OAuth2"
	VaultStrategy StrategyType = "Vault"
)

type SwapMap

type SwapMap struct {
	Distance float64
	Index    int
}

type SwapMaps

type SwapMaps []SwapMap

func (SwapMaps) Len

func (me SwapMaps) Len() int

func (SwapMaps) Less

func (me SwapMaps) Less(left, right int) bool

func (SwapMaps) Swap

func (me SwapMaps) Swap(left, right int)

Jump to

Keyboard shortcuts

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