Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateOptimalBufferSize(cfg *configTypes.ServerConfig) int
- func DecodeNpub(npub string) (string, error)
- func DetermineEventCategory(kind int) string
- func EnsureFileExists(filePath, examplePath string)
- func FetchPubkeysFromDomains(domains []string) ([]string, error)
- func GetClientIP(r *http.Request) string
- func GetLogger(component string) *slog.Logger
- func InitializeLoggers(cfg *cfgTypes.ServerConfig)
- func LoadRelayMetadata(filename string) error
- func LoadRelayMetadataJSON() error
- func RelayInfoHandler(w http.ResponseWriter, r *http.Request)
- func SendToBackupRelay(backupURL string, evt relay.Event) error
- func SerializeEvent(evt relay.Event) string
- func StartPeriodicLogTrimmer(logFilePath string, maxSizeMB int, checkIntervalMinutes int, backupCount int)
- func ToInt(i interface{}) *int
- func ToInt64(i interface{}) *int64
- func ToIntArray(i interface{}) []int
- func ToStringArray(i interface{}) []string
- func ToTagsMap(i interface{}) map[string][]string
- func ToTime(data interface{}) *time.Time
- type CachedDomains
- type JSONLogWriter
- func (j *JSONLogWriter) Close()
- func (j *JSONLogWriter) Enabled(ctx context.Context, level slog.Level) bool
- func (j *JSONLogWriter) Handle(ctx context.Context, r slog.Record) error
- func (j *JSONLogWriter) WithAttrs(attrs []slog.Attr) slog.Handler
- func (j *JSONLogWriter) WithGroup(name string) slog.Handler
- type LoggerRegistry
- type NostrJSON
- type PrettyLogWriter
- type RelayMetadata
Constants ¶
const ( // Conservative Note Size BufferMessageSizeLimit = 5000 // 5 KiloBytes )
Constants based on your database analysis
Variables ¶
var Registry = &LoggerRegistry{ loggers: make(map[string]*slog.Logger), }
Global registry instance
Functions ¶
func CalculateOptimalBufferSize ¶
func CalculateOptimalBufferSize(cfg *configTypes.ServerConfig) int
CalculateOptimalBufferSize determines buffer size based on system resources
func DecodeNpub ¶
DecodeNpub decodes a Bech32 encoded npub to its corresponding pubkey
func DetermineEventCategory ¶
func EnsureFileExists ¶
func EnsureFileExists(filePath, examplePath string)
func FetchPubkeysFromDomains ¶
FetchPubkeysFromDomains fetches nostr.json pubkeys from multiple domains with caching.
func GetClientIP ¶
func InitializeLoggers ¶
func InitializeLoggers(cfg *cfgTypes.ServerConfig)
InitializeLoggers sets up the central logging system with the given configuration
func LoadRelayMetadata ¶
func LoadRelayMetadataJSON ¶
func LoadRelayMetadataJSON() error
func RelayInfoHandler ¶
func RelayInfoHandler(w http.ResponseWriter, r *http.Request)
func SerializeEvent ¶
SerializeEvent manually constructs the JSON string for event serialization according to NIP-01
func StartPeriodicLogTrimmer ¶
func StartPeriodicLogTrimmer(logFilePath string, maxSizeMB int, checkIntervalMinutes int, backupCount int)
StartPeriodicLogTrimmer starts a goroutine that periodically checks and manages log size
func ToIntArray ¶
func ToIntArray(i interface{}) []int
func ToStringArray ¶
func ToStringArray(i interface{}) []string
Types ¶
type CachedDomains ¶
type JSONLogWriter ¶
type JSONLogWriter struct {
// contains filtered or unexported fields
}
JSONLogWriter writes logs in a pretty-printed JSON array format
func NewJSONLogWriter ¶
func NewJSONLogWriter(filePath string, level slog.Level, maxSizeMB int, backupCount int) *JSONLogWriter
NewJSONLogWriter creates a new instance of JSONLogWriter
func (*JSONLogWriter) Close ¶
func (j *JSONLogWriter) Close()
Close is now a no-op since logs are written properly on each entry.
type LoggerRegistry ¶
type LoggerRegistry struct {
// contains filtered or unexported fields
}
LoggerRegistry maintains a map of all loggers by component name
type PrettyLogWriter ¶
type PrettyLogWriter struct {
// contains filtered or unexported fields
}
PrettyLogWriter writes logs ONLY to a file