sources

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCloudSQLOpts added in v0.1.0

func GetCloudSQLOpts(ipType, userAgent string, useIAM bool) ([]cloudsqlconn.Option, error)

GetCloudSQLDialOpts retrieve dial options with the right ip type and user agent for cloud sql databases.

func GetIAMAccessToken added in v0.8.0

func GetIAMAccessToken(ctx context.Context) (string, error)

func GetIAMPrincipalEmailFromADC added in v0.4.0

func GetIAMPrincipalEmailFromADC(ctx context.Context, dbType string) (string, error)

GetIAMPrincipalEmailFromADC finds the email associated with ADC

func InitConnectionSpan added in v0.0.5

func InitConnectionSpan(ctx context.Context, tracer trace.Tracer, sourceType, sourceName string) (context.Context, trace.Span)

InitConnectionSpan adds a span for database pool connection initialization

func Register added in v0.7.0

func Register(sourceType string, factory SourceConfigFactory) bool

Register registers a new source type with its factory. It returns false if the type is already registered.

Types

type Cache added in v0.27.0

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

Cache is a thread-safe, expiring key-value store

func NewCache added in v0.27.0

func NewCache(onEvict OnEvictFunc) *Cache

NewCache creates a new cache and cleans up every 55 min

func (*Cache) Delete added in v0.27.0

func (c *Cache) Delete(key string)

Delete manually evicts an item

func (*Cache) DeleteExpired added in v0.27.0

func (c *Cache) DeleteExpired()

DeleteExpired removes all expired items

func (*Cache) Get added in v0.27.0

func (c *Cache) Get(key string) (any, bool)

Get retrieves an item from the cache

func (*Cache) Set added in v0.27.0

func (c *Cache) Set(key string, value any)

Set adds an item to the cache

type Dialect added in v0.0.3

type Dialect string

Dialect represents the dialect type of a database.

func (*Dialect) String added in v0.0.3

func (i *Dialect) String() string

func (*Dialect) UnmarshalYAML added in v0.0.3

func (i *Dialect) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type IPType added in v0.0.3

type IPType string

func (*IPType) String added in v0.0.3

func (i *IPType) String() string

func (*IPType) UnmarshalYAML added in v0.0.3

func (i *IPType) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type Item added in v0.27.0

type Item struct {
	Value     any
	ExpiresAt int64 // Unix nano timestamp
}

Item holds the cached value and its expiration timestamp

func (Item) IsExpired added in v0.27.0

func (item Item) IsExpired() bool

IsExpired checks if the item is expired

type OnEvictFunc added in v0.27.0

type OnEvictFunc func(key string, value any)

OnEvictFunc is the signature for the callback

type Source

type Source interface {
	SourceType() string
	ToConfig() SourceConfig
}

Source is the interface for the source itself.

type SourceConfig added in v0.0.2

type SourceConfig interface {
	SourceConfigType() string
	Initialize(ctx context.Context, tracer trace.Tracer) (Source, error)
}

SourceConfig is the interface for configuring a source.

func DecodeConfig added in v0.7.0

func DecodeConfig(ctx context.Context, sourceType string, name string, decoder *yaml.Decoder) (SourceConfig, error)

DecodeConfig decodes a source configuration using the registered factory for the given type.

type SourceConfigFactory added in v0.7.0

type SourceConfigFactory func(ctx context.Context, name string, decoder *yaml.Decoder) (SourceConfig, error)

SourceConfigFactory defines the function signature for creating a SourceConfig.

Jump to

Keyboard shortcuts

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