utils

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: MIT Imports: 20 Imported by: 16

Documentation

Index

Constants

View Source
const (
	APP_NAME      = "swagchat-api"
	API_VERSION   = "v0"
	BUILD_VERSION = "v0.9.1"

	KEY_LENGTH        = 32
	TOKEN_LENGTH      = 32
	HEADER_API_KEY    = "X-SwagChat-Api-Key"
	HEADER_API_SECRET = "X-SwagChat-Api-Secret"
	HEADER_USER_ID    = "X-SwagChat-User-Id"
)

Variables

View Source
var (
	Cfg           *Config
	IsShowVersion bool
)
View Source
var AppLogger *zap.Logger

Functions

func AppendStrings

func AppendStrings(strings ...string) string

func CreateApiKey added in v0.6.0

func CreateApiKey() string

func CreateUuid

func CreateUuid() string

func GenerateToken added in v0.5.0

func GenerateToken(n int) string

func IsUrl

func IsUrl(checkUrl string) error

func IsValidId

func IsValidId(id string) bool

func Join

func Join(stringSlice []string, delimiter string, enclosure string) string

func MakePrepareForInExpression

func MakePrepareForInExpression(target interface{}) (string, map[string]interface{})

func MergeMap

func MergeMap(baseMap map[string]interface{}, mergeMaps ...map[string]interface{}) map[string]interface{}

func RemoveDuplicate

func RemoveDuplicate(args []string) []string

func SearchStringValueInSlice added in v0.2.0

func SearchStringValueInSlice(slice []string, value string) bool

Types

type Config

type Config struct {
	Version      string
	Port         string
	Profiling    bool
	DemoPage     bool `yaml:"demoPage"`
	ErrorLogging bool `yaml:"errorLogging"`
	Logging      *Logging
	Storage      *Storage
	Datastore    *Datastore
	Rtm          *Rtm
	Notification *Notification
}

type Datastore added in v0.4.0

type Datastore struct {
	Provider        string
	TableNamePrefix string `yaml:"tableNamePrefix"`

	// SQLite
	SqlitePath string `yaml:"sqlitePath"`

	// MySQL, GCP SQL
	User              string
	Password          string
	Database          string
	MaxIdleConnection string `yaml:"maxIdleConnection"`
	MaxOpenConnection string `yaml:"maxOpenConnection"`
	Master            *ServerInfo
	Replicas          []*ServerInfo
}

type Dispatcher

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

func NewDispatcher

func NewDispatcher(max int) *Dispatcher

func (*Dispatcher) Wait

func (d *Dispatcher) Wait()

func (*Dispatcher) Work

func (d *Dispatcher) Work(ctx context.Context, proc WorkFunc)

type JSONText

type JSONText json.RawMessage

func (JSONText) MarshalJSON

func (j JSONText) MarshalJSON() ([]byte, error)

MarshalJSON returns j as the JSON encoding of j.

func (*JSONText) Scan

func (j *JSONText) Scan(src interface{}) error

Scan stores the src in *j. No validation is done.

func (JSONText) String

func (j JSONText) String() string

Pretty printing for JSONText types

func (*JSONText) Unmarshal

func (j *JSONText) Unmarshal(v interface{}) error

Unmarshal unmarshal's the json in j to v, as in json.Unmarshal.

func (*JSONText) UnmarshalJSON

func (j *JSONText) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data

func (JSONText) Value

func (j JSONText) Value() (driver.Value, error)

Value returns j as a value. This does a validating unmarshal into another RawMessage. If j is invalid json, it returns an error.

type Logging added in v0.4.0

type Logging struct {
	Level string
}

type Notification added in v0.4.0

type Notification struct {
	Provider            string
	RoomTopicNamePrefix string `yaml:"roomTopicNamePrefix"`
	DefaultBadgeCount   string `yaml:"defaultBadgeCount"`

	// AWS SNS
	AwsRegion                string `yaml:"awsRegion"`
	AwsAccessKeyId           string `yaml:"awsAccessKeyId"`
	AwsSecretAccessKey       string `yaml:"awsSecretAccessKey"`
	AwsApplicationArnIos     string `yaml:"awsApplicationArnIos"`
	AwsApplicationArnAndroid string `yaml:"awsApplicationArnAndroid"`
}

type Rtm added in v0.8.4

type Rtm struct {
	Provider       string
	DirectEndpoint string `yaml:"directEndpoint"`
	QueEndpoint    string `yaml:"queEndpoint"`
	QueTopic       string `yaml:"queTopic"`
}

type ServerInfo added in v0.9.1

type ServerInfo struct {
	Host           string
	Port           string
	ServerName     string `yaml:"serverName"`
	ServerCaPath   string `yaml:"serverCaPath"`
	ClientCertPath string `yaml:"clientCertPath"`
	ClientKeyPath  string `yaml:"clientKeyPath"`
}

type Storage added in v0.4.0

type Storage struct {
	Provider string

	// Local
	BaseUrl   string `yaml:"baseUrl"`
	LocalPath string `yaml:"localPath"`

	// GCP Storage, AWS S3
	UploadBucket       string `yaml:"uploadBucket"`
	UploadDirectory    string `yaml:"uploadDirectory"`
	ThumbnailBucket    string `yaml:"thumbnailBucket"`
	ThumbnailDirectory string `yaml:"thumbnailDirectory"`

	// GCP Storage
	GcpProjectId string `yaml:"gcpProjectId"`
	GcpJwtPath   string `yaml:"gcpJwtPath"`

	// AWS S3
	AwsRegion          string `yaml:"awsRegion"`
	AwsAccessKeyId     string `yaml:"awsAccessKeyId"`
	AwsSecretAccessKey string `yaml:"awsSecretAccessKey"`
}

type WorkFunc

type WorkFunc func(context.Context)

Jump to

Keyboard shortcuts

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