models

package
v0.0.0-...-c59394f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: Apache-2.0 Imports: 2 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// NodesKey for the nodes info storage key
	NodesKey = "sqs.nodes"
)
View Source
const SquadKeyPrefix = "sqs.squad"

SquadKeyPrefix prefix of the storage key for squad

Variables

This section is empty.

Functions

func MessageKey

func MessageKey(userID int64, queueName string, index int64) string

MessageKey for message storage key

func QueueListKey

func QueueListKey(userID int64) string

QueueListKey for queue list storage key

func QueueMaxIDKey

func QueueMaxIDKey(userID int64, queueName string) string

QueueMaxIDKey for record the max id has been distributed

func SquadKey

func SquadKey(userID int64, queueName string, squadName string) string

SquadKey returns the key for the given params

Types

type HTTPStatus

type HTTPStatus struct {
	HTTPStatusMeta
	Data interface{} `json:"data"`
}

HTTPStatus contains handleGetStatus of a failed request

type HTTPStatusMeta

type HTTPStatusMeta struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

HTTPStatusMeta for a http response body data structure

type Incrementer

type Incrementer interface {
	// Increment try to increment the current value of the key.
	// It will returns non-nil error if current value exists but not a number string or
	// failed to increment by resource race.
	// result is the result value of the key if the increment succeed.
	Increment(key string, number int) (result int64, err error)
}

Incrementer defines increment a integer value in a transaction

type KV

type KV interface {
	Get(key string) (string, error)
	Put(key string, value string) error
	Delete(key string) error
}

KV defines underlying key/value database

type Message

type Message struct {
	UserID    int64  `json:"-"`
	QueueName string `json:"-"`
	Content   string `json:"content"`
	Index     int64  `json:"message_id"`
}

Message contains info

type NodeInfo

type NodeInfo struct {
	Addr   string `json:"addr"`
	CPU    int    `json:"cpu"`
	Memory int    `json:"memory"`
}

NodeInfo contains the basic stats information of one node

type NodeRequestParams

type NodeRequestParams struct {
	Token     string `json:"token"`
	QueueName string `json:"queue_name"`
	SquadName string `json:"squad_name,omitempty"`
}

NodeRequestParams contains the basic info of every request

type NodeSlice

type NodeSlice []NodeInfo

NodeSlice contains a slice of nodes

func (NodeSlice) Len

func (ss NodeSlice) Len() int

func (NodeSlice) Less

func (ss NodeSlice) Less(i, j int) bool

func (NodeSlice) Swap

func (ss NodeSlice) Swap(i, j int)

type Queue

type Queue struct {
	UserID int64
	Name   string
}

Queue contains name-message map

func NewQueue

func NewQueue(userID int64, name string) *Queue

NewQueue returns a new queue

type Squad

type Squad struct {
	Name              string
	UserID            int64
	QueueName         string
	ReceivedMessageID int64
	RecentPushedAt    time.Time
}

Squad is a record for one queue processed index

func (*Squad) Key

func (s *Squad) Key() string

Key returns the key of this Squad

type UserAuth

type UserAuth struct {
	//AccessKey for sqs basic key
	AccessKey string `json:"access_key"`
	// Secret for user auth
	SecretKey string `json:"secret_key"`
}

UserAuth for one user auth info

type Watcher

type Watcher interface {
	Watch(key string) (value <-chan string)
	Close() error
}

Watcher defines a watcher

Jump to

Keyboard shortcuts

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