Skip to content

Commit

Permalink
feat: add caching debug headers directive.
Browse files Browse the repository at this point in the history
  • Loading branch information
vuongxuongminh committed Apr 21, 2022
1 parent cc32baf commit ce6842d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 45 deletions.
92 changes: 47 additions & 45 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,61 @@
{$GBOX_GLOBAL_DIRECTIVES}
}

{$GBOX_SERVER_NAME:localhost} {
log {
level {$GBOX_LOG_LEVEL:INFO}
}
{$GBOX_SERVER_NAME:localhost}

@admin_auth {
path /admin/graphql
method POST
expression `{$GBOX_ENABLED_CACHING:true} == true && {$GBOX_ENABLED_ADMIN_AUTH:false} == true`
}
log

@metrics {
path {$GBOX_METRICS_PATH:/metrics}
method GET
expression `{$GBOX_ENABLED_METRICS:false} == true`
}
@admin_auth {
path /admin/graphql
method POST
expression `{$GBOX_ENABLED_CACHING:true} == true && {$GBOX_ENABLED_ADMIN_AUTH:false} == true`
}

route {
encode gzip
@metrics {
path {$GBOX_METRICS_PATH:/metrics}
method GET
expression `{$GBOX_ENABLED_METRICS:false} == true`
}

metrics @metrics
route {
encode gzip

basicauth @admin_auth bcrypt {
{$GBOX_ADMIN_USERNAME:gbox} {$GBOX_ADMIN_PASSWORD:JDJhJDE0JHBXUk5YMjVRYlRtTjN3SERiU0Rrei4uMW4ub0FhaHZlY0hnbWtBMUNSLnhmeEUuUDVOOW5l}
}
metrics @metrics

gbox {
upstream {$GBOX_UPSTREAM} {
{$GBOX_UPSTREAM_REVERSE_PROXY_DIRECTIVES}
basicauth @admin_auth bcrypt {
{$GBOX_ADMIN_USERNAME:gbox} {$GBOX_ADMIN_PASSWORD:JDJhJDE0JHBXUk5YMjVRYlRtTjN3SERiU0Rrei4uMW4ub0FhaHZlY0hnbWtBMUNSLnhmeEUuUDVOOW5l}
}

gbox {
upstream {$GBOX_UPSTREAM} {
{$GBOX_UPSTREAM_REVERSE_PROXY_DIRECTIVES}
}
fetch_schema_interval {$GBOX_FETCH_SCHEMA_INTERVAL:10m}
complexity {
enabled {$GBOX_ENABLED_COMPLEXITY:true}
node_count_limit {$GBOX_NODE_COUNT_LIMIT:60}
max_complexity {$GBOX_MAX_COMPLEXITY:60}
max_depth {$GBOX_MAX_DEPTH:15}
}
disabled_introspection {$GBOX_DISABLED_INTROSPECTION:false}
disabled_playgrounds {$GBOX_DISABLED_PLAYGROUNDS:false}
caching {
enabled {$GBOX_ENABLED_CACHING:true}
store_dsn {$GBOX_STORE_DSN:freecache://?cache_size=5368709120}
rules {
{$GBOX_CACHING_RULES}
}
fetch_schema_interval {$GBOX_FETCH_SCHEMA_INTERVAL:10m}
complexity {
enabled {$GBOX_ENABLED_COMPLEXITY:true}
node_count_limit {$GBOX_NODE_COUNT_LIMIT:60}
max_complexity {$GBOX_MAX_COMPLEXITY:60}
max_depth {$GBOX_MAX_DEPTH:15}
varies {
{$GBOX_CACHING_VARIES}
}
disabled_introspection {$GBOX_DISABLED_INTROSPECTION:false}
disabled_playgrounds {$GBOX_DISABLED_PLAYGROUNDS:false}
caching {
enabled {$GBOX_ENABLED_CACHING:true}
store_dsn {$GBOX_STORE_DSN:freecache://?cache_size=5368709120}
rules {
{$GBOX_CACHING_RULES}
}
varies {
{$GBOX_CACHING_VARIES}
}
auto_invalidate_cache {$GBOX_AUTO_INVALIDATE_CACHE:true}
type_keys {
{$GBOX_CACHING_TYPE_KEYS}
}
{$GBOX_EXTRA_DIRECTIVES}
auto_invalidate_cache {$GBOX_AUTO_INVALIDATE_CACHE:true}
debug_headers {$GBOX_CACHING_DEBUG_HEADERS:true}
}

respond /healthz "OK"
{$GBOX_EXTRA_DIRECTIVES}
}
}

respond /healthz "OK"
}
4 changes: 4 additions & 0 deletions caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Caching struct {
// of this query have type User with id's 3, all cached query result related with id 3 of User type will be purged.
AutoInvalidate bool

// Add debug headers like query result cache key,
// plan cache key and query result had types keys or not...
DebugHeaders bool

logger *zap.Logger
store *CachingStore
ctxBackground context.Context
Expand Down

0 comments on commit ce6842d

Please sign in to comment.