utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 18 Imported by: 16

Documentation

Index

Constants

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

	DEFAULT_SERVER_PORT          = "9000"
	DEFAULT_PROFILING            = ""
	DEFAULT_SERVER_LOGGING_LEVEL = "development"
	DEFAULT_STORAGE              = "local"
	DEFAULT_DATASTORE            = "sqlite"
	DEFAULT_MESSAGING            = ""
	DEFAULT_NOTIFICATION         = ""

	DEFAULT_REALTIMESERVER_ENDPOINT = ""

	DEFAULT_LOCAL_STORAGE_BASE_URL = "http://localhost:9000/" + API_VERSION
	DEFAULT_LOCAL_STORAGE_PATH     = "data/assets"

	DEFAULT_MYSQL_MAXIDLECONNECTION = "10"
	DEFAULT_MYSQL_MAXOPENCONNECTION = "10"

	DEFAULT_SQLITE_DATABASE_PATH = "/tmp/swagchat_test.db"

	DEFAULT_MYSQL_USESSL = ""
)

Variables

View Source
var AppLogger *zap.Logger

Functions

func AppendStrings

func AppendStrings(strings ...string) string

func CreateUuid

func CreateUuid() 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 ApiServer

type ApiServer struct {
	Port         string
	Profiling    string
	LoggingLevel string
	Storage      string
	Datastore    string
	Messaging    string
	Notification string
}

type AwsS3

type AwsS3 struct {
	Region              string
	AccessKeyId         string
	SecretAccessKey     string
	Acl                 string
	UserUploadBucket    string
	UserUploadDirectory string
	ThumbnailBucket     string
	ThumbnailDirectory  string
}

type AwsSns

type AwsSns struct {
	Region              string
	AccessKeyId         string
	SecretAccessKey     string
	ApplicationArn      string
	RoomTopicNamePrefix string
}

type Config

type Config struct {
	ApiServer      *ApiServer
	RealtimeServer *RealtimeServer
	// Storage
	LocalStorage *LocalStorage
	GcpStorage   *GcpStorage
	AwsS3        *AwsS3
	// Datastore
	Sqlite *Sqlite
	Mysql  *Mysql
	GcpSql *GcpSql
	// Messaging
	GcpPubsub *GcpPubsub
	// Notification
	AwsSns *AwsSns
}

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 GcpPubsub

type GcpPubsub struct {
	ThumbnailTopic    string
	PushMessageTopic  string
	Scope             string
	JwtConfigFilepath string
}

type GcpSql

type GcpSql struct {
	ProjectId         string
	SqlInstanceId     string
	User              string
	Password          string
	Database          string
	MasterHost        string
	MasterPort        string
	MaxIdleConnection string
	MaxOpenConnection string
	UseSSL            string
	ServerCaPath      string
	ClientCertPath    string
	ClientKeyPath     string
}

type GcpStorage

type GcpStorage struct {
	ProjectId           string
	Scope               string
	JwtConfigFilepath   string
	UserUploadBucket    string
	UserUploadDirectory string
	ThumbnailBucket     string
	ThumbnailDirectory  string
}

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 LocalStorage

type LocalStorage struct {
	BaseUrl string
	Path    string
}

type Mysql

type Mysql struct {
	User              string
	Password          string
	Database          string
	MasterHost        string
	MasterPort        string
	MaxIdleConnection string
	MaxOpenConnection string
	UseSSL            string
	ServerName        string
	ServerCaPath      string
	ClientCertPath    string
	ClientKeyPath     string
}

type RealtimeServer

type RealtimeServer struct {
	Endpoint string
}

type Sqlite

type Sqlite struct {
	DatabasePath string
}

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