Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureDiscordHTTPClient(ip string, timeout time.Duration, disableHttp2 bool, globalOverrides string, ...)
- func CopyResponseToResponseWriter(resp *http.Response, respWriter *http.ResponseWriter) error
- func EnvGet(name string, defaultVal string) string
- func EnvGetBool(name string, defaultVal bool) bool
- func EnvGetInt(name string, defaultVal int) int
- func EnvMustGet(name string) string
- func Generate429(resp *http.ResponseWriter)
- func GetBotGlobalLimit(token string, user *BotUserResponse) (uint, error)
- func GetBotId(token string) string
- func GetMetricsPath(route string) string
- func GetOptimisticBucketPath(url string, method string) string
- func GetSnowflakeCreatedAt(snowflake string) (time.Time, error)
- func HashCRC64(data string) uint64
- func InitMemberList(knownMembers []string, port int, proxyPort string, manager *QueueManager) *memberlist.Memberlist
- func IsNumericInput(str string) bool
- func IsSnowflake(str string) bool
- func ProcessRequest(ctx context.Context, item *QueueItem) (*http.Response, error)
- func SetLogger(l *logrus.Logger)
- func StartMetrics(addr string)
- func StartProfileServer()
- type BotGatewayResponse
- type BotUserResponse
- type ClusterGlobalRateLimiter
- type GlobalHook
- type NirnDelegate
- type NirnEvents
- type QueueChannel
- type QueueItem
- type QueueManager
- func (m *QueueManager) CreateMux() *http.ServeMux
- func (m *QueueManager) DiscordRequestHandler(resp http.ResponseWriter, req *http.Request)
- func (m *QueueManager) GetEventDelegate() *NirnEvents
- func (m *QueueManager) GetRequestRoutingInfo(req *http.Request, token string) (routingHash uint64, path string, queueType QueueType)
- func (m *QueueManager) HandleGlobal(w http.ResponseWriter, r *http.Request)
- func (m *QueueManager) SetCluster(cluster *memberlist.Memberlist, proxyPort string)
- func (m *QueueManager) Shutdown()
- type QueueType
- type RequestQueue
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", }) RequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "nirn_proxy_requests", Help: "Request histogram", Buckets: []float64{.1, .25, 1, 2.5, 5, 20}, }, []string{"method", "status", "route", "clientId"}) ConnectionsOpen = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "nirn_proxy_open_connections", Help: "Gauge for client connections currently open with the proxy", }, []string{"method", "route"}) RequestsRoutedSent = promauto.NewCounter(prometheus.CounterOpts{ Name: "nirn_proxy_requests_routed_sent", Help: "Counter for requests routed from this node into other nodes", }) RequestsRoutedRecv = promauto.NewCounter(prometheus.CounterOpts{ Name: "nirn_proxy_requests_routed_received", Help: "Counter for requests received from other nodes", }) RequestsRoutedError = promauto.NewCounter(prometheus.CounterOpts{ Name: "nirn_proxy_requests_routed_error", Help: "Counter for failed requests routed from this node", }) )
Functions ¶
func CopyResponseToResponseWriter ¶ added in v1.1.0
func CopyResponseToResponseWriter(resp *http.Response, respWriter *http.ResponseWriter) error
func EnvGetBool ¶ added in v1.2.1
func EnvMustGet ¶
func Generate429 ¶ added in v1.2.2
func Generate429(resp *http.ResponseWriter)
func GetBotGlobalLimit ¶
func GetBotGlobalLimit(token string, user *BotUserResponse) (uint, error)
func GetMetricsPath ¶
func GetOptimisticBucketPath ¶
func InitMemberList ¶ added in v1.1.0
func InitMemberList(knownMembers []string, port int, proxyPort string, manager *QueueManager) *memberlist.Memberlist
func IsNumericInput ¶
func IsSnowflake ¶
func ProcessRequest ¶
func StartMetrics ¶
func StartMetrics(addr string)
func StartProfileServer ¶
func StartProfileServer()
Types ¶
type BotGatewayResponse ¶
type BotUserResponse ¶
type BotUserResponse struct { Id string `json:"id"` Username string `json:"username"` Discrim string `json:"discriminator"` }
func GetBotUser ¶
func GetBotUser(token string) (*BotUserResponse, error)
type ClusterGlobalRateLimiter ¶ added in v1.1.0
func NewClusterGlobalRateLimiter ¶ added in v1.1.0
func NewClusterGlobalRateLimiter() *ClusterGlobalRateLimiter
func (*ClusterGlobalRateLimiter) FireGlobalRequest ¶ added in v1.1.0
func (*ClusterGlobalRateLimiter) Take ¶ added in v1.1.0
func (c *ClusterGlobalRateLimiter) Take(botHash uint64, botLimit uint)
type GlobalHook ¶ added in v1.2.1
type GlobalHook struct { }
func (*GlobalHook) Levels ¶ added in v1.2.1
func (h *GlobalHook) Levels() []logrus.Level
type NirnDelegate ¶ added in v1.1.0
type NirnDelegate struct { memberlist.Delegate // contains filtered or unexported fields }
func (NirnDelegate) GetBroadcasts ¶ added in v1.1.0
func (d NirnDelegate) GetBroadcasts(overhead int, limit int) [][]byte
func (NirnDelegate) LocalState ¶ added in v1.1.0
func (d NirnDelegate) LocalState(join bool) []byte
func (NirnDelegate) MergeRemoteState ¶ added in v1.1.0
func (d NirnDelegate) MergeRemoteState(buf []byte, join bool)
func (NirnDelegate) NodeMeta ¶ added in v1.1.0
func (d NirnDelegate) NodeMeta(limit int) []byte
func (NirnDelegate) NotifyMsg ¶ added in v1.1.0
func (d NirnDelegate) NotifyMsg(msg []byte)
type NirnEvents ¶ added in v1.1.0
type NirnEvents struct { memberlist.EventDelegate OnJoin func(node *memberlist.Node) OnLeave func(node *memberlist.Node) }
func (NirnEvents) NotifyJoin ¶ added in v1.1.0
func (d NirnEvents) NotifyJoin(node *memberlist.Node)
func (NirnEvents) NotifyLeave ¶ added in v1.1.0
func (d NirnEvents) NotifyLeave(node *memberlist.Node)
func (NirnEvents) NotifyUpdate ¶ added in v1.1.0
func (d NirnEvents) NotifyUpdate(node *memberlist.Node)
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 QueueManager ¶ added in v1.1.0
func NewQueueManager ¶ added in v1.1.0
func NewQueueManager(bufferSize int, maxBearerLruSize int) *QueueManager
func (*QueueManager) CreateMux ¶ added in v1.1.0
func (m *QueueManager) CreateMux() *http.ServeMux
func (*QueueManager) DiscordRequestHandler ¶ added in v1.1.0
func (m *QueueManager) DiscordRequestHandler(resp http.ResponseWriter, req *http.Request)
func (*QueueManager) GetEventDelegate ¶ added in v1.1.0
func (m *QueueManager) GetEventDelegate() *NirnEvents
func (*QueueManager) GetRequestRoutingInfo ¶ added in v1.2.0
func (*QueueManager) HandleGlobal ¶ added in v1.1.0
func (m *QueueManager) HandleGlobal(w http.ResponseWriter, r *http.Request)
func (*QueueManager) SetCluster ¶ added in v1.1.0
func (m *QueueManager) SetCluster(cluster *memberlist.Memberlist, proxyPort string)
func (*QueueManager) Shutdown ¶ added in v1.1.0
func (m *QueueManager) Shutdown()
type RequestQueue ¶
func NewRequestQueue ¶
func (*RequestQueue) Queue ¶
func (q *RequestQueue) Queue(req *http.Request, res *http.ResponseWriter, path string, pathHash uint64) error
Click to show internal directories.
Click to hide internal directories.