kv

package
v0.38.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TokenMaxAge = time.Hour

TokenMaxAge is the default expiration window for auth tokens.

Variables

This section is empty.

Functions

func GenerateToken added in v0.37.7

func GenerateToken(secret string) string

GenerateToken creates a signed token with timestamp and nonce. Format: {timestamp}.{nonce}.{signature}

func GetValue added in v0.37.8

func GetValue(host, auth, key string) (string, error)

GetValue retrieves a value from the KV store via HTTP

func SetValue added in v0.37.8

func SetValue(host, auth, key, value string) error

SetValue stores a value in the KV store via HTTP

func ValidateToken added in v0.37.7

func ValidateToken(token, secret string, maxAge time.Duration) bool

ValidateToken checks if the token is valid and not expired.

Types

type KeyValueStore

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

In-memory key-value store

func NewKeyValueStore

func NewKeyValueStore() *KeyValueStore

func (*KeyValueStore) Clear

func (kv *KeyValueStore) Clear()

func (*KeyValueStore) Get

func (kv *KeyValueStore) Get(w http.ResponseWriter, r *http.Request)

Get retrieves a value by key from the key-value store.

func (*KeyValueStore) GetVal

func (kv *KeyValueStore) GetVal(key string) (val string, ok bool)

func (*KeyValueStore) Set

func (kv *KeyValueStore) Set(w http.ResponseWriter, r *http.Request)

Set stores a value for a key in the key-value store.

func (*KeyValueStore) SetVal

func (kv *KeyValueStore) SetVal(key, val string)

type Server

type Server struct {
	Listener net.Listener
	Secret   string

	Port int
	// contains filtered or unexported fields
}

func StartHttpServer

func StartHttpServer(kvStore *KeyValueStore) (*Server, func(), error)

Jump to

Keyboard shortcuts

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