-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: Redesign the protocol (Breaking Change)! #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| ## custom internal protocol defined | ||||||
|
|
||||||
| ### ProtocolRequestIDKey | ||||||
|
|
||||||
| Set request id | ||||||
|
|
||||||
| ### X-FS-Mem | ||||||
|
|
||||||
| force store in memory | ||||||
|
|
||||||
| ### ProtocolCacheStatusKey | ||||||
|
|
||||||
| Response cache status with name, like X-Cache: HIT from memory | ||||||
|
|
||||||
| ### PrefetchCacheKey | ||||||
|
|
||||||
| Prefetch cache, value 1 mean prefetch, 0 mean not prefetch | ||||||
|
|
||||||
| ### CacheTime | ||||||
|
|
||||||
| Set force `Cache-Control` Cache time, value is seconds, like `CacheTime: 60` mean `Cache-Control: max-age=60` | ||||||
|
|
||||||
| ### InternalTraceKey | ||||||
|
|
||||||
| Internal trace key, value is 1 or 0, 1 mean enable trace, 0 mean disable trace | ||||||
|
|
||||||
| ### InternalStoreUrl | ||||||
|
|
||||||
| Set force store-url, value is string, like `http://example.com/somepath/app.apk` | ||||||
|
|
||||||
| ### InternalSwapfile | ||||||
|
|
||||||
| Show response swapfile info, debug now! | ||||||
|
|
||||||
| ### InternalFillRangePercent | ||||||
|
|
||||||
| Set fill range percent, value is int, like `InternalFillRangePercent: 50` mean fill 50% of response | ||||||
|
||||||
| Set fill range percent, value is int, like `InternalFillRangePercent: 50` mean fill 50% of response | |
| Set fill range percent, value is int, like `i-x-fp: 50` mean fill 50% of response |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,7 +21,7 @@ import ( | |||||
| "github.com/omalloc/tavern/api/defined/v1/storage" | ||||||
| "github.com/omalloc/tavern/api/defined/v1/storage/object" | ||||||
| "github.com/omalloc/tavern/contrib/log" | ||||||
| "github.com/omalloc/tavern/internal/constants" | ||||||
| "github.com/omalloc/tavern/internal/protocol" | ||||||
| "github.com/omalloc/tavern/metrics" | ||||||
| "github.com/omalloc/tavern/pkg/iobuf" | ||||||
| xhttp "github.com/omalloc/tavern/pkg/x/http" | ||||||
|
|
@@ -92,15 +92,15 @@ func (c *Caching) setXCache(resp *http.Response) { | |||||
| return | ||||||
| } | ||||||
|
|
||||||
| resp.Header.Set(constants.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, "(tavern/4.0)"}, " ")) | ||||||
| resp.Header.Set(protocol.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, c.bucket.StoreType(), "(tavern/4.0)"}, " ")) | ||||||
|
||||||
| resp.Header.Set(protocol.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, c.bucket.StoreType(), "(tavern/4.0)"}, " ")) | |
| resp.Header.Set(protocol.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, c.bucket.Type(), "(tavern/4.0)"}, " ")) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,9 +46,9 @@ func New(opt *storage.BucketConfig, sharedkv storage.SharedKV) (storage.Bucket, | |
| mb := &memoryBucket{ | ||
| fs: vfs.NewMem(), | ||
| path: "/", | ||
| driver: opt.Driver, | ||
| driver: opt.Driver, // storage.TypeInMemory | ||
| dbPath: storage.TypeInMemory, | ||
| storeType: storage.TypeInMemory, | ||
| storeType: opt.Type, | ||
| weight: 100, // default weight | ||
|
Comment on lines
46
to
52
|
||
| sharedkv: sharedkv, | ||
| cache: lru.New[object.IDHash, storage.Mark](opt.MaxObjectLimit), // in-memory object size | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README examples use
CacheTime: 60, but the actual header key isX-CacheTime(protocol.CacheTime). Please update the example to use the real header name so operators can copy/paste it correctly.