lib

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MajorUnknown      = "unk"
	MajorChannels     = "channels"
	MajorGuilds       = "guilds"
	MajorWebhooks     = "webhooks"
	MajorInvites      = "invites"
	MajorInteractions = "interactions"
)
View Source
const EpochDiscord = 1420070400000

Variables

View Source
var (
	ErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
		Name: "nirn_proxy_error",
		Help: "The total number of errors when processing requests",
	})

	RequestSummary = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Name:       "nirn_proxy_requests",
		Help:       "Request histogram",
		Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
	}, []string{"method", "status", "route", "clientId"})
)

Functions

func ConfigureDiscordHTTPClient

func ConfigureDiscordHTTPClient(ip string)

func GetBotGlobalLimit

func GetBotGlobalLimit(token string) (uint, error)

func GetBotId

func GetBotId(token string) string

func GetMetricsPath

func GetMetricsPath(route string) string

func GetOptimisticBucketPath

func GetOptimisticBucketPath(url string, method string) string

func GetSnowflakeCreatedAt

func GetSnowflakeCreatedAt(snowflake string) (time.Time, error)

func HashCRC64

func HashCRC64(data string) uint64

func IsNumericInput

func IsNumericInput(str string) bool

func IsSnowflake

func IsSnowflake(str string) bool

func ProcessRequest

func ProcessRequest(item *QueueItem) *http.Response

func SetLogger

func SetLogger(l *logrus.Logger)

func StartMetrics

func StartMetrics(addr string)

func StartProfileServer

func StartProfileServer()

Types

type BotGatewayResponse

type BotGatewayResponse struct {
	SessionStartLimit map[string]int `json:"session_start_limit"`
}

type QueueChannel

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

type QueueItem

type QueueItem struct {
	Req *http.Request
	Res *http.ResponseWriter
	// contains filtered or unexported fields
}

type RequestQueue

type RequestQueue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRequestQueue

func NewRequestQueue(processor func(item *QueueItem) *http.Response, globalLimit uint, bufferSize int64) *RequestQueue

func (*RequestQueue) Queue

func (q *RequestQueue) Queue(req *http.Request, res *http.ResponseWriter) (string, *http.Response, error)

Jump to

Keyboard shortcuts

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