helpers

package
v0.0.0-...-32823bc Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_FORM_SIZE = 1024 * 1024 * 1024

Variables

View Source
var EmailRegexp *regexp.Regexp
View Source
var GithubClient = func() *http.Client {
	transport := &http.Transport{
		MaxIdleConns:       200,
		IdleConnTimeout:    60 * time.Second,
		DisableCompression: false,
	}
	return &http.Client{Transport: transport}
}()
View Source
var InitRegex = (func() bool {
	EmailRegexp = regexp.MustCompile(emailregex)
	return true
}())

Functions

func CanRetry

func CanRetry(maxAllowed int, retryCount int, routingKey *string) bool

func GetGithubUserData

func GetGithubUserData(tokenStruct *GithubToken) *models.GithubUser

func GetNextChannel

func GetNextChannel(currentChannel string, list string) (*rabbit.WorkerList, string)

Helper for Amq Consumer to get next queue name to be used for retrial

func GetSession

func GetSession(sessionId string) (*models.UserRedis, error)

func HasEssentials

func HasEssentials(req *request.Request) bool

Validates a batch request body

func IsEmail

func IsEmail(email string) bool

func IsMultipart

func IsMultipart(header string) bool

func IsValidMGRequest

func IsValidMGRequest(req *request.Request) bool

func LogListener

func LogListener(packet amqp.Delivery) (*models.Log, *models.Batch, gocql.UUID, gocql.UUID, int, bool, bool, error)

A common helper to perform basic checks on a published key on Log queues This helper won't take any decision on the packet, avoiding any arbitary flaws @return

Log: Log Model
Batch: Batch Model
log_id: UUID of Log Model
batch_id: UUID of Batch Model
retryCount: int
Nack: Negative acknowledge a packet
ACK: Positive acknowledge a packet
error: error

func NextChannelToTry

func NextChannelToTry(tried map[string]bool) *rabbit.WorkerList

Returns a provider which hasn't been used yet

func ReadMultiPartForm

func ReadMultiPartForm(boundary string, body io.Reader) *multipart.Form

func SaveSession

func SaveSession(sessionId string, data *models.GithubUser) bool

func UpdateStats

func UpdateStats(user_id gocql.UUID, key string)

Updates stats for the day

Types

type GithubToken

type GithubToken struct {
	Access_Token string `json:access_token`
	Scope        string `json:scope`
	Token_Type   string `json:token_type`
}

func GetGithubUserToken

func GetGithubUserToken(code string, state string) *GithubToken

Jump to

Keyboard shortcuts

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