Documentation ¶
Index ¶
- Constants
- func ByteToStruct(msg []byte, obj interface{}) error
- func Contains(haystack []string, needle string) bool
- func CopyFile(src string, dst string) error
- func FormatJSON(data []byte) ([]byte, error)
- func InitZapLog(service string) *zap.Logger
- func JSONMarshal(t interface{}) ([]byte, error)
- func PrettyJsonString(data []byte) (string, error)
- func ProtoStructToStruct(msg *structpb.Struct, obj interface{}) error
- func RandString(n int) string
- func ReadFileToStruct(filePath string, obj interface{}) error
- func StructToMapInterface(in interface{}) (map[string]interface{}, error)
- func ToProtoStruct(in interface{}) (*structpb.Struct, error)
- func ZipFile(fdList []FileData) ([]byte, error)
- func ZipFileByTopLevelDir(fdList []FileData) (map[string][]byte, error)
- type FileData
Constants ¶
View Source
const ( ProjectName = "flame" // General ALL = "all" ID = "id" Design = "design" Message = "message" Errors = "errors" GenericError = "GenericError" InternalUser = "sys" // Status Status = "status" StatusSuccess = "Success" StatusError = "Error" // Database MONGODB = "mongodb" MySQL = "mysql" // Database Fields //TODO append Field to distinguish the fields DBFieldMongoID = "_id" DBFieldUserId = "userid" DBFieldId = "id" DBFieldDesignId = "designid" DBFieldCode = "code" DBFieldSchema = "schema" DBFieldSchemaId = "schemaid" DBFieldJobId = "jobid" DBFieldTaskId = "taskid" DBFieldState = "state" DBFieldRole = "role" DBFieldTaskLog = "log" DBFieldIsPublic = "ispublic" DBFieldTaskDirty = "dirty" DBFieldTaskKey = "key" DBFieldTimestamp = "timestamp" DBFieldComputeId = "computeid" DBFieldComputeRegion = "region" DBFieldURL = "url" DBFieldAgentStatuses = "agentstatuses" DBFieldGroupAssociation = "groupassociation" // Port numbers ApiServerRestApiPort = 10100 // REST API port NotifierGrpcPort = 10101 // for notification and push ControllerRestApiPort = 10102 // Controller REST API port AgentGrpcPort = 10103 // for flamelet - application MetaServerPort = 10104 // meta data update and retrieval (Experimental) // Service names Agent = "flamelet" ApiServer = "apiserver" Controller = "controller" Notifier = "notifier" MetaServer = "metaserver" Deployer = "deployer" CliTool = "flamectl" // file permission FilePerm0644 = 0644 FilePerm0700 = 0700 FilePerm0755 = 0755 NumTokensInRestEndpoint = 3 NumTokensInEndpoint = 2 TaskConfigFile = "config" TaskCodeFile = "code.zip" LogDirPath = "/var/log/" + ProjectName DefaultRealm = "default" RealmSep = "/" )
Variables ¶
This section is empty.
Functions ¶
func ByteToStruct ¶
func FormatJSON ¶
FormatJSON prettify the json by adding tabs
func InitZapLog ¶
InitZapLog Zap Logger initialization
https://pkg.go.dev/go.uber.org/zap#ReplaceGlobals https://pkg.go.dev/go.uber.org/zap#hdr-Choosing_a_Logger
In most circumstances, use the SugaredLogger. It's 4-10x faster than most other structured logging packages and has a familiar, loosely-typed API.
sugar := logger.Sugar() sugar.Infow("Failed to fetch URL.", // Structured context as loosely typed key-value pairs. "url", url, "attempt", 3, "backoff", time.Second, ) sugar.Infof("Failed to fetch URL: %s", url)
In the unusual situations where every microsecond matters, use the Logger. It's even faster than the SugaredLogger, but only supports structured logging.
logger.Info("Failed to fetch URL.", // Structured context as strongly typed fields. zap.String("url", url), zap.Int("attempt", 3), zap.Duration("backoff", time.Second), )
func JSONMarshal ¶ added in v0.1.3
Marshal JSON to escape HTML characters like <, > while printing
func PrettyJsonString ¶ added in v0.1.2
func ProtoStructToStruct ¶
func RandString ¶
func ReadFileToStruct ¶ added in v0.2.2
func StructToMapInterface ¶
StructToMapInterface converts any struct interface into map interface using json de-coding/encoding.
func ToProtoStruct ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.