ss

package module
v0.0.0-...-5c68377 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

README

ss

Serverless Service Framework

Codeship Status for palchukovsky/ss

Documentation

Index

Constants

View Source
const EntityIDSize = 16

EntityIDSize is the size of EntityID in bytes.

View Source
const UserIDSize = EntityIDSize

UserIDSize is the size of UserID in bytes.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(value bool) *bool

BoolPtr converts bool value into pointer on bool.

func BoolPtrIfSet

func BoolPtrIfSet(value bool) *bool

BoolPtrIfSet converts bool value into pointer on bool.

func IsBoolSet

func IsBoolSet(value *bool) bool

IsBoolSet returns true if bool set and true.

func MarshalLogMsgAttrDump

func MarshalLogMsgAttrDump(
	value interface{},
	destination map[string]interface{},
)

func Set

func Set(s Service)

Set sets service without any initialization and checks.

Types

type AWSAccessKey

type AWSAccessKey struct {
	IsUsed bool
	// contains filtered or unexported fields
}

func NewAWSAccessKey

func NewAWSAccessKey(id, secret string) AWSAccessKey

func (*AWSAccessKey) UnmarshalJSON

func (key *AWSAccessKey) UnmarshalJSON(source []byte) error

type AWSConfig

type AWSConfig struct {
	AccountID string       `json:"accountId"`
	Region    string       `json:"region"`
	AccessKey AWSAccessKey `json:"accessKey"`
	Gateway   struct {
		App struct {
			ID string `json:"id"`
			// Endpoint is the app API gateway full path, set by builder.
			Endpoint string `json:"endpoint"`
		} `json:"app"`
		Auth struct {
			ID string `json:"id"`
		} `json:"auth"`
	} `json:"gateway"`

	// LambdaTimeout is the max lambda run time before a forced kill.
	LambdaTimeout time.Duration
}

type Build

type Build struct {
	Version    string `json:"version"`    // verbose product version
	Commit     string `json:"commit"`     // full repository commid ID
	ID         string `json:"id"`         // verbose shot build ID to compare
	Builder    string `json:"builder"`    // build ID on builder
	Maintainer string `json:"maintainer"` // person who started build
}

func (Build) GetEnvironment

func (build Build) GetEnvironment() string

func (Build) IsProd

func (build Build) IsProd() bool

IsProd returns true if build is production.

type Config

type Config struct {
	SS struct {
		Service ServiceConfig `json:"service"`
		Build   Build         `json:"build"`
		Log     logConfig     `json:"log"`
	} `json:"ss"`
}

//////////////////////////////////////////////////////////////////////////////

type ConfigWrapper

type ConfigWrapper interface {
	GetBasePtr() interface{}
	GetSSPtr() *Config
}

type ConnectionID

type ConnectionID string

ConnectionID is a connection ID.

func (ConnectionID) MarshalLogMsg

func (id ConnectionID) MarshalLogMsg(destination map[string]interface{})

type Date

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

func NewDate

func NewDate(year uint, month time.Month, day uint) Date

func NewDateFromTime

func NewDateFromTime(source time.Time) Date

func (Date) After

func (date Date) After(rhs Date) bool

func (Date) Day

func (date Date) Day() uint

func (Date) MarshalDynamoDBAttributeValue

func (date Date) MarshalDynamoDBAttributeValue(
	result *dynamodb.AttributeValue,
) error

func (Date) MarshalText

func (date Date) MarshalText() ([]byte, error)

func (Date) Month

func (date Date) Month() time.Month

func (Date) Number

func (date Date) Number() uint

func (Date) String

func (date Date) String() string

func (*Date) UnmarshalDynamoDBAttributeValue

func (date *Date) UnmarshalDynamoDBAttributeValue(
	source *dynamodb.AttributeValue,
) error

func (*Date) UnmarshalText

func (date *Date) UnmarshalText(source []byte) error

func (Date) Year

func (date Date) Year() uint

type DateOrTime

type DateOrTime struct {
	Value      Time
	IsDateOnly bool
}

DateOrTime is an object which could have date and time, or date only.

func NewDateOrTime

func NewDateOrTime(value Time, isDateOnly bool) DateOrTime

NewDateOrTime creates new DateOrTime.

func (DateOrTime) IsEqual

func (time DateOrTime) IsEqual(rhs DateOrTime) bool

IsEqual reports whether values represent the same time instant.

func (DateOrTime) MarshalDynamoDBAttributeValue

func (time DateOrTime) MarshalDynamoDBAttributeValue(
	result *dynamodb.AttributeValue,
) error

MarshalDynamoDBAttributeValue implements serialization for Dynamodb.

func (DateOrTime) MarshalText

func (time DateOrTime) MarshalText() ([]byte, error)

func (DateOrTime) String

func (time DateOrTime) String() string

func (*DateOrTime) UnmarshalDynamoDBAttributeValue

func (time *DateOrTime) UnmarshalDynamoDBAttributeValue(
	source *dynamodb.AttributeValue,
) error

UnmarshalDynamoDBAttributeValue implements reading from Dynamodb.

func (*DateOrTime) UnmarshalText

func (time *DateOrTime) UnmarshalText(source []byte) error

type DeviceID

type DeviceID string

func NewDeviceID

func NewDeviceID(source string) DeviceID

func (DeviceID) MarshalLogMsg

func (id DeviceID) MarshalLogMsg(destination map[string]interface{})

type EntityID

type EntityID uuid.UUID

EntityID is an abstract project entity ID.

func NewEntityID

func NewEntityID() EntityID

NewEntityID generates new entity ID.

func ParseEntityID

func ParseEntityID(source string) (EntityID, error)

ParseEntityID parses ID in string.

func (EntityID) MarshalBinary

func (id EntityID) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (EntityID) MarshalDynamoDBAttributeValue

func (id EntityID) MarshalDynamoDBAttributeValue(
	result *dynamodb.AttributeValue,
) error

MarshalDynamoDBAttributeValue implements serialization for Dynamodb.

func (EntityID) MarshalText

func (id EntityID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (EntityID) String

func (id EntityID) String() string

String returns ID as string.

func (*EntityID) UnmarshalBinary

func (id *EntityID) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*EntityID) UnmarshalDynamoDBAttributeValue

func (id *EntityID) UnmarshalDynamoDBAttributeValue(
	source *dynamodb.AttributeValue,
) error

UnmarshalDynamoDBAttributeValue implements reading from Dynamodb.

func (*EntityID) UnmarshalText

func (id *EntityID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type FirebaseCloudMessagingToken

type FirebaseCloudMessagingToken string

func NewFirebaseCloudMessagingToken

func NewFirebaseCloudMessagingToken(source string) FirebaseCloudMessagingToken

func (FirebaseCloudMessagingToken) MarshalLogMsg

func (token FirebaseCloudMessagingToken) MarshalLogMsg(
	destination map[string]interface{},
)

func (FirebaseCloudMessagingToken) String

func (token FirebaseCloudMessagingToken) String() string

type FirebaseConfig

type FirebaseConfig struct {
	IsUsed bool
	// contains filtered or unexported fields
}

func (FirebaseConfig) GetJSON

func (config FirebaseConfig) GetJSON() []byte

func (*FirebaseConfig) UnmarshalJSON

func (config *FirebaseConfig) UnmarshalJSON(source []byte) error

type Log

type Log interface {
	LogStream

	Started()

	// NewLogSession creates the log session which allows setting records
	// prefix for each session message.
	NewSession(newPrefix func() LogPrefix) LogSession

	// CheckExit makes final check for panic, writes all error data.
	// It has to be the one and the lowest level check in the call.
	// Each goroutine should has at the beggining sonthing like:
	// defer func() { service.log.CheckExit(recover()) }()
	CheckExit(panicValue interface{})
}

func NewLog

func NewLog(projectPackage string, module string, config Config) Log

type LogMsg

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

func NewLogMsg

func NewLogMsg(format string, args ...interface{}) *LogMsg

func (*LogMsg) Add

func (m *LogMsg) Add(source LogMsgAttr) *LogMsg

func (*LogMsg) AddAttrs

func (m *LogMsg) AddAttrs(source []LogMsgAttr) *LogMsg

func (*LogMsg) AddCurrentStack

func (m *LogMsg) AddCurrentStack() *LogMsg

func (*LogMsg) AddDump

func (m *LogMsg) AddDump(source interface{}) *LogMsg

func (*LogMsg) AddErr

func (m *LogMsg) AddErr(source error) *LogMsg

func (*LogMsg) AddFailPrefix

func (m *LogMsg) AddFailPrefix(prefix LogPrefix) *LogMsg

func (*LogMsg) AddInfoPrefix

func (m *LogMsg) AddInfoPrefix(prefix LogPrefix) *LogMsg

func (*LogMsg) AddPanic

func (m *LogMsg) AddPanic(source interface{}) *LogMsg

func (*LogMsg) AddParent

func (m *LogMsg) AddParent(source *LogMsg)

func (*LogMsg) AddRequest

func (m *LogMsg) AddRequest(source interface{}) *LogMsg

func (*LogMsg) AddRequestID

func (m *LogMsg) AddRequestID(source string) *LogMsg

func (*LogMsg) AddResponse

func (m *LogMsg) AddResponse(source interface{}) *LogMsg

func (*LogMsg) AddVal

func (m *LogMsg) AddVal(name string, value interface{}) *LogMsg

func (LogMsg) ConvertAttributesToJSON

func (m LogMsg) ConvertAttributesToJSON() []byte

func (LogMsg) ConvertToJSON

func (m LogMsg) ConvertToJSON() []byte

func (LogMsg) Error

func (m LogMsg) Error() string

func (LogMsg) GetErrs

func (m LogMsg) GetErrs() []logMsgAttrErr

func (LogMsg) GetLevel

func (m LogMsg) GetLevel() logLevel

func (LogMsg) GetMessage

func (m LogMsg) GetMessage() string

func (LogMsg) MarshalAttributesMap

func (m LogMsg) MarshalAttributesMap() map[string]interface{}

func (LogMsg) MarshalMap

func (m LogMsg) MarshalMap() map[string]interface{}

func (*LogMsg) SetLevel

func (m *LogMsg) SetLevel(source logLevel)

type LogMsgAttr

type LogMsgAttr interface {
	MarshalLogMsg(destination map[string]interface{})
}

func NewLogMsgAttrRequestDumps

func NewLogMsgAttrRequestDumps(value interface{}) []LogMsgAttr

type LogMsgAttrDumpGroup

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

func NewLogMsgAttrDumpGroup

func NewLogMsgAttrDumpGroup(
	groupNode string,
	value interface{},
) LogMsgAttrDumpGroup

func (LogMsgAttrDumpGroup) MarshalLogMsg

func (a LogMsgAttrDumpGroup) MarshalLogMsg(destination map[string]interface{})

type LogMsgAttrVal

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

func NewLogMsgAttrVal

func NewLogMsgAttrVal(node string, value interface{}) LogMsgAttrVal

func (LogMsgAttrVal) MarshalLogMsg

func (a LogMsgAttrVal) MarshalLogMsg(destination map[string]interface{})

type LogPrefix

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

func NewLogPrefix

func NewLogPrefix(newFailAttrs func() []LogMsgAttr) LogPrefix

func (LogPrefix) Add

func (lp LogPrefix) Add(a LogMsgAttr) LogPrefix

func (LogPrefix) AddRequestID

func (lp LogPrefix) AddRequestID(source string) LogPrefix

func (LogPrefix) AddVal

func (lp LogPrefix) AddVal(name string, value interface{}) LogPrefix

type LogSession

type LogSession interface {
	LogStream

	// NewLogSession creates the log session which allows setting records
	// prefix for each session message.
	NewSession(newPrefix func() LogPrefix) LogSession
}

type LogSource

type LogSource interface{ Log() LogStream }

type LogStream

type LogStream interface {
	NoCopy

	Debug(*LogMsg)
	Info(*LogMsg)
	Warn(*LogMsg)
	Error(*LogMsg)
	Panic(*LogMsg)

	CheckPanic(panicValue interface{}, errorMessage string)
	// contains filtered or unexported methods
}

Log describes product log interface.

type NoCopy

type NoCopy interface {
	Lock()
	Unlock()
}

Lock is a no-op used by -copylocks checker from `go vet`.

type NoCopyImpl

type NoCopyImpl struct{}

Lock is a no-op used by -copylocks checker from `go vet`.

func (*NoCopyImpl) Lock

func (*NoCopyImpl) Lock()

func (*NoCopyImpl) Unlock

func (*NoCopyImpl) Unlock()

type RSAPrivateKey

type RSAPrivateKey struct {
	IsUsed bool
	// contains filtered or unexported fields
}

func (RSAPrivateKey) Get

func (key RSAPrivateKey) Get() *rsa.PrivateKey

func (*RSAPrivateKey) UnmarshalJSON

func (key *RSAPrivateKey) UnmarshalJSON(jsonSource []byte) error

type Service

type Service interface {
	NoCopy

	Now() Time

	Log() Log
	Product() string
	Name() string
	Config() ServiceConfig
	Build() Build

	StartLambda(getFailInfo func() []LogMsgAttr)
	CompleteLambda(panicValue interface{})
	SubscribeForLambdaTimeout() <-chan struct{}

	NewBuildEntityName(name string) string

	NewAWSConfig() aws.Config
	NewAWSSessionV1() *session.Session

	Firebase() *firebase.App
}

Service is the root interface of the service.

var S Service

S is the standalone service instance.

func NewService

func NewService(
	product string,
	projectPackage string,
	params ServiceParams,
	configWrapper ConfigWrapper,
) Service

NewService creates new service instance.

type ServiceConfig

type ServiceConfig struct {
	Endpoint     string         `json:"endpoint"`
	HeaderPrefix string         `json:"headerPrefix"`
	AWS          AWSConfig      `json:"aws"`
	Firebase     FirebaseConfig `json:"firebase"`
	PrivateKey   struct {
		RSA RSAPrivateKey `json:"rsa"`
	} `json:"privateKey"`
	App struct {
		MinVersion [4]uint `json:"minVer"`
		Domain     string  `json:"domain"`
		Android    struct {
			Package string `json:"package"`
		} `json:"android"`
		IOS struct {
			Bundle string `json:"bundle"`
		} `json:"ios"`
	} `json:"app"`
}

func (ServiceConfig) IsExtraLogEnabled

func (ServiceConfig) IsExtraLogEnabled() bool

type ServiceParams

type ServiceParams struct {
	IsAWS      bool
	IsFirebase bool
	IsAuth     bool
}

ServiceParams is a set of service parameters.

type Time

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

func NewTime

func NewTime(source stdtime.Time) Time

func NewTimeFromDate

func NewTimeFromDate(source Date) Time

func Now

func Now() Time

Now return current platform time in correct time zone.

func (Time) Add

func (time Time) Add(duration time.Duration) Time

func (Time) AddDate

func (time Time) AddDate(years int, months int, days int) Time

func (Time) After

func (time Time) After(rhs Time) bool

func (Time) Before

func (time Time) Before(rhs Time) bool

func (Time) Equal

func (time Time) Equal(rhs Time) bool

func (Time) Get

func (time Time) Get() stdtime.Time

func (Time) MarshalDynamoDBAttributeValue

func (time Time) MarshalDynamoDBAttributeValue(
	result *dynamodb.AttributeValue,
) error

func (Time) MarshalText

func (time Time) MarshalText() ([]byte, error)

func (Time) String

func (time Time) String() string

func (Time) UTC

func (time Time) UTC() Time

func (Time) Unix

func (time Time) Unix() int64

func (*Time) UnmarshalDynamoDBAttributeValue

func (time *Time) UnmarshalDynamoDBAttributeValue(
	source *dynamodb.AttributeValue,
) error

UnmarshalDynamoDBAttributeValue implements reading from Dynamodb.

func (*Time) UnmarshalText

func (time *Time) UnmarshalText(source []byte) error

type UserID

type UserID struct{ EntityID }

ss.UserID is a user ID.

func LoadUserID

func LoadUserID(source EntityID) UserID

LoadUserID loads UserID from entity ID.

func NewUserID

func NewUserID() UserID

NewUserID generates new user ID.

func ParseUserID

func ParseUserID(source string) (UserID, error)

LoadUserID loads UserID from entity ID.

func (UserID) MarshalLogMsg

func (user UserID) MarshalLogMsg(destination map[string]interface{})

Jump to

Keyboard shortcuts

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