silverdile

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

silverdile

Google App Engine Image Serviceのようなものを2nd genでも利用するために生まれた

アーキテクチャ

v1

変換要求が来る度に画像を生成し、エッジキャッシュに乗せて返す

v2

変換要求が来た時に、変換後ObjectBucketを参照し、そこにすでに画像があれば、それを返す。 画像がない場合、画像を生成し、変換後ObjectBucketに保存して、それを返す。

v3

アーキテクチャはv2と同様。 singleflightやcache layerを独自に入れやすいようにv2と比べて処理が分解されて、必要最低限のものだけになった。 Cloud Runで動かすことを意識しているが、GAE 2nd Genでも動く。

Setup

オリジナルの画像が入ったBucketNameにPrefixとして alter- を付けたBucketを作成する。 alter- Bucketに必要であれば Lifecycle を設定して、変換後イメージの削除を行う。

機能

Resize

Pathとして /{bucket}/{object}/=s??? を指定すると画像の長辺を???のサイズにした状態で画像を返す

Example

Limitation
  • Size 0 ~ 2560

Dev

Local GAE Run

go run github.com/sinmetalcraft/silverdile/app

Deploy

gcloud app deploy app/app.yaml

Documentation

Index

Constants

View Source
const MaxResizeSize = 2560
View Source
const MinResizeSize = 0

Variables

View Source
var InternalError failure.StringCode = "InternalError"
View Source
var InvalidArgument failure.StringCode = "InvalidArgument"
View Source
var NotFound failure.StringCode = "NotFound"

Functions

func ImageHandler

func ImageHandler(w http.ResponseWriter, r *http.Request)

Types

type ImageOption

type ImageOption struct {
	Bucket             string
	Object             string
	Size               int
	CacheControlMaxAge int // Pathから指定はできず、App側で指定する
}

func BuildImageOption

func BuildImageOption(path string) (*ImageOption, error)

BuildImageOption is Request URLからImageOptionを生成する App Engine Image Serviceと同じ雰囲気のURLを利用する時に使う

期待する形式 `/{bucket}/{object}` `/{bucket}/{object}/=sXXX`

Directories

Path Synopsis
v3

Jump to

Keyboard shortcuts

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