waitingroom

package
v0.0.0-...-c7651eb Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const EnableDomainKey = "queue-domains"

制限中のドメインリスト

View Source
const SuffixCacheEnable = "_enable_cache"
View Source
const SuffixCurrentNo = "_current_no"
View Source
const SuffixLastNo = "_last_no"
View Source
const SuffixPermittedNo = "_permitted_no"
View Source
const SuffixPermittedNoLock = "_permitted_no_lock"
View Source
const WhiteListKey = "queue-whitelist"

Variables

View Source
var ErrClientNotIncrese = errors.New("client not increase")

Functions

This section is empty.

Types

type AccessController

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

func NewAccessController

func NewAccessController(config *Config, redisClient *redis.Client, cache *Cache) *AccessController

func (*AccessController) Do

func (a *AccessController) Do(ctx context.Context, e *echo.Echo) error

type Cache

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

func NewCache

func NewCache(redisClient *redis.Client, config *Config) *Cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

func (*Cache) Exists

func (c *Cache) Exists(key string) bool

func (*Cache) Get

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

func (*Cache) GetAndFetchIfExpired

func (c *Cache) GetAndFetchIfExpired(ctx context.Context, key string) (string, error)

func (*Cache) Set

func (c *Cache) Set(key, value string, ttl time.Duration)

func (*Cache) ZScanAndFetchIfExpired

func (c *Cache) ZScanAndFetchIfExpired(ctx context.Context, key, target string) ([]string, error)

type Client

type Client struct {
	SerialNumber         int64  // 通し番号
	ID                   string // ユーザー固有ID
	TakeSerialNumberTime int64  // シリアルナンバーを取得するUNIXTIME
	// contains filtered or unexported fields
}

func NewClientByContext

func NewClientByContext(ctx echo.Context, sc *securecookie.SecureCookie) (*Client, error)

type Config

type Config struct {
	LogLevel string
	Listener string

	PermittedAccessSec  int    `mapstructure:"permitted_access_sec,omitempty" validate:"required"`                                                  // アクセス許可後アクセスできる時間
	EntryDelaySec       int64  `mapstructure:"entry_delay_sec,omitempty" validate:"required"`                                                       // 初回エントリーをDelayさせる秒数
	QueueEnableSec      int    `mapstructure:"queue_enable_sec,omitempty" validate:"required"`                                                      // 待合室を有効にしておく時間
	PermitIntervalSec   int    `mapstructure:"permit_interval_sec,omitempty" validate:"required,gtefield=CacheTTLSec,gtefield=NegativeCacheTTLSec"` // アクセス許可判定周期
	PermitUnitNumber    int64  `mapstructure:"permit_unit_number,omitempty" validate:"required"`                                                    // アクセス許可する単位(PermitIntervalSecあたりPermitUnitNumber許可)
	CacheTTLSec         int    `mapstructure:"cache_ttl_sec,omitempty" validate:"required"`                                                         // ローカルメモリキャッシュTTL
	NegativeCacheTTLSec int    `mapstructure:"negative_cache_ttl_sec,omitempty" validate:"required"`                                                // ローカルメモリネガティブキャッシュTTL
	PublicHost          string `mapstructure:"public_host,omitempty"`                                                                               // 公開URLのホスト
	SlackApiToken       string `mapstructure:"slack_api_token,omitempty"`                                                                           // Slack Api Token
	SlackChannel        string `mapstructure:"slack_channel,omitempty"`                                                                             // Slack Channel
	EnableOtel          bool   `mapstructure:"enable_otel,omitempty"`                                                                               // OpenTelemetryによるトレースを有効にする
}

type Error

type Error struct {
	StatusCode int
	Message    string
	RawErr     error
}

Error Apiのエラーを定義する構造体

func NewError

func NewError(statusCode int, err error, message string, params ...interface{}) *Error

NewError エラー構造体を初期化して返却します

func (*Error) Error

func (err *Error) Error() string

Error Errorインターフェースの必須定義メソッド

func (*Error) Unwrap

func (err *Error) Unwrap() error

type QueueConfirmation

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

func NewQueueConfirmation

func NewQueueConfirmation(
	sc *securecookie.SecureCookie,
	config *Config,
	redisClient *redis.Client,
	cache *Cache,
) *QueueConfirmation

func (*QueueConfirmation) Do

func (p *QueueConfirmation) Do(c echo.Context) error

type QueueResult

type QueueResult struct {
	ID                  string
	Enabled             bool  `json:"enabled"`
	PermittedClient     bool  `json:"permitted_client"`
	SerialNo            int64 `json:"serial_no"`
	PermittedNo         int64 `json:"permitted_no"`
	RemainingWaitSecond int64 `json:"remaining_wait_second"`
}

type Site

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

func NewSite

func NewSite(c context.Context, domain string, config *Config, r *redis.Client, cache *Cache) *Site

func (*Site) EnableQueue

func (s *Site) EnableQueue() error

制限中ドメインリストに、ロックを取りながらドメインを追加する

func (*Site) Reset

func (s *Site) Reset() error

Jump to

Keyboard shortcuts

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