infrastructure

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CloudStorageURL string = "https://storage.googleapis.com/"

Variables

This section is empty.

Functions

func AppEnv

func AppEnv() string

AppEnv returns application envirionment of 'staging', 'production'.

func CreateBlankFileToGCS

func CreateBlankFileToGCS(ctx context.Context, fileID string, fileEntity string, fileRequest FileRequest) (string, error)

func CreateBlankFileToPublicGCS

func CreateBlankFileToPublicGCS(ctx context.Context, fileID string, fileEntity string, fileRequest FileRequest) (string, error)

func CreateFileToGCS

func CreateFileToGCS(ctx context.Context, bucketName, filePath, contentType string, contents []byte) error

CreateFileToGCS creates object to GCS.

func CreateTask

func CreateTask(ctx context.Context, name string, eta time.Time, message string) (*taskspb.Task, error)

func GetFileFromGCS

func GetFileFromGCS(ctx context.Context, bucketName, filePath string) ([]byte, error)

GetFileFromGCS gets object from GCS.

func GetGCSSignedURL

func GetGCSSignedURL(ctx context.Context, bucket string, key string, method string, contentType string) (string, error)

GetGCSSignedURL generates signed-URL for GCS object.

func GetPublicBackgroundImageURL

func GetPublicBackgroundImageURL(id string) string

GetPublicBackgroundImageURL returns public image file URL in GCS.

func GetPublicBackgroundMusicURL

func GetPublicBackgroundMusicURL(id string) string

GetPublicBackgroundMusicURL returns public audio file URL in GCS.

func LessonCompressingTaskName

func LessonCompressingTaskName(lessonID int64, currentTime time.Time, requestID string) string

func LocationID

func LocationID() string

func MaterialBucketName

func MaterialBucketName() string

MaterialBucketName is return bucket name each environments.

func OriginURL

func OriginURL() string

OriginURL return API root url each current env

func ProjectID

func ProjectID() string

ProjectID returns Google Cloud Project ID.

func PublicBucketName

func PublicBucketName() string

PublicBucketName is return public bucket name each environments.

func ServiceAccountID

func ServiceAccountID() string

ServiceAccountID returns full account id.

func ServiceAccountName

func ServiceAccountName() string

ServiceAccountName returns email address format of google service account.

func SetAppEnv

func SetAppEnv(appEnv string) error

SetAppEnv sets application envirionment string.

func StorageObjectFilePath

func StorageObjectFilePath(entity string, id string, extension string) string

Types

type EntityBelongToFile

type EntityBelongToFile struct {
	UserID int64
}

type FileRequest

type FileRequest struct {
	ID          string `json:"id"`
	Entity      string `json:"entity"`
	Extension   string `json:"extension"`
	ContentType string `json:"contentType"`
}

type SignedURL

type SignedURL struct {
	FileID    string `json:"fileID"`
	SignedURL string `json:"signedURL"`
}

type SignedURLs

type SignedURLs struct {
	SignedURLs []SignedURL `json:"signedURLs"`
}

type StorageObjectRequest

type StorageObjectRequest struct {
	LessonID     int64         `json:"lessonID"`
	FileRequests []FileRequest `json:"fileRequests"`
}

Jump to

Keyboard shortcuts

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