mirror of
https://github.com/glowingblue/flarum-ext-redis-setup.git
synced 2026-03-22 15:07:53 +01:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77ad7422e7 | ||
|
|
4f261dbee4 | ||
|
|
d59ebfa684 | ||
|
|
b03ca35d54 | ||
|
|
4c7a5d377d | ||
|
|
6545bfdffc | ||
|
|
2f2cce1abe | ||
|
|
78082dc842 | ||
|
|
e02001333b | ||
|
|
44fa68c278 | ||
|
|
139d687e1b | ||
|
|
9061552db9 | ||
|
|
eab24f9adc | ||
|
|
94049c5183 | ||
|
|
96af9b58f6 | ||
|
|
69c73e2397 | ||
|
|
c2ddd30cd7 | ||
|
|
f3e8fc0243 | ||
|
|
8f82fbe078 | ||
|
|
4e668a4098 | ||
|
|
68b5b8f871 | ||
|
|
27601d7f61 | ||
|
|
4d7828548b | ||
|
|
9a0fe54c37 | ||
|
|
b308a07d8d | ||
|
|
c167010796 | ||
|
|
e94701d39c | ||
|
|
57f7647fc3 | ||
|
|
8c976e3fc0 | ||
|
|
590d0084c5 | ||
|
|
fcd833a248 | ||
|
|
3284a36926 | ||
|
|
68af330669 | ||
|
|
09a30f786d | ||
|
|
68a5cafdfc |
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
max_line_length = 100
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
quote_type = single
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{json,yml,yaml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = false
|
||||||
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
**Resolves**
|
||||||
|
<!-- include a link to the issue -->
|
||||||
|
|
||||||
|
**Changes proposed in this pull request:**
|
||||||
|
<!-- mention the pages and/or components which have been impacted -->
|
||||||
|
|
||||||
|
**Reviewers should focus on:**
|
||||||
|
<!-- ask for feedback on specific changes you are unsure about -->
|
||||||
|
|
||||||
|
**Screenshot**
|
||||||
|
<!-- include an image of the most relevant user-facing change, if any -->
|
||||||
13
.github/workflows/backend.yml
vendored
Normal file
13
.github/workflows/backend.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: GB Redis Setup PHP
|
||||||
|
|
||||||
|
on: [workflow_dispatch, push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@1.x
|
||||||
|
with:
|
||||||
|
enable_backend_testing: false
|
||||||
|
enable_phpstan: true
|
||||||
|
php_versions: '["8.1", "8.2", "8.3", "8.4"]'
|
||||||
|
|
||||||
|
backend_directory: .
|
||||||
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -1,16 +0,0 @@
|
|||||||
name: Build JavaScript assets
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
- uses: flarum/action-build@master
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
23
.github/workflows/frontend.yml
vendored
Normal file
23
.github/workflows/frontend.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: GB Redis Setup JS
|
||||||
|
|
||||||
|
on: [workflow_dispatch, push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
|
||||||
|
with:
|
||||||
|
enable_bundlewatch: false
|
||||||
|
enable_prettier: true
|
||||||
|
enable_typescript: false
|
||||||
|
|
||||||
|
frontend_directory: ./js
|
||||||
|
backend_directory: .
|
||||||
|
js_package_manager: yarn
|
||||||
|
main_git_branch: 1.x
|
||||||
|
|
||||||
|
git_actor_name: ${{ vars.GIT_ACTOR_NAME }}
|
||||||
|
git_actor_email: ${{ vars.GIT_ACTOR_EMAIL }}
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
|
||||||
|
git_actor_token: ${{ secrets.GIT_ACTOR_TOKEN }}
|
||||||
156
.gitignore
vendored
156
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
# Created by https://www.toptal.com/developers/gitignore/api/vim,yarn,node,linux,macos,windows,visualstudiocode,composer
|
# Created by https://www.toptal.com/developers/gitignore/api/vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,yarn,node,linux,macos,windows,visualstudiocode,composer
|
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains
|
||||||
|
|
||||||
### Composer ###
|
### Composer ###
|
||||||
composer.phar
|
composer.phar
|
||||||
@@ -7,7 +7,110 @@ composer.phar
|
|||||||
|
|
||||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||||
# composer.lock
|
composer.lock
|
||||||
|
|
||||||
|
### JetBrains ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### JetBrains Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||||
|
.idea/**/sonarlint/
|
||||||
|
|
||||||
|
# SonarQube Plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||||
|
.idea/**/sonarIssues.xml
|
||||||
|
|
||||||
|
# Markdown Navigator plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||||
|
.idea/**/markdown-navigator.xml
|
||||||
|
.idea/**/markdown-navigator-enh.xml
|
||||||
|
.idea/**/markdown-navigator/
|
||||||
|
|
||||||
|
# Cache file creation bug
|
||||||
|
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||||
|
.idea/$CACHE_FILE$
|
||||||
|
|
||||||
|
# CodeStream plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||||
|
.idea/codestream.xml
|
||||||
|
|
||||||
### Linux ###
|
### Linux ###
|
||||||
*~
|
*~
|
||||||
@@ -33,6 +136,7 @@ composer.phar
|
|||||||
# Icon must end with two \r
|
# Icon must end with two \r
|
||||||
Icon
|
Icon
|
||||||
|
|
||||||
|
|
||||||
# Thumbnails
|
# Thumbnails
|
||||||
._*
|
._*
|
||||||
|
|
||||||
@@ -61,6 +165,9 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Lock file => as we don't use npm, but yarn.
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
@@ -108,6 +215,9 @@ typings/
|
|||||||
# Optional eslint cache
|
# Optional eslint cache
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
# Microbundle cache
|
# Microbundle cache
|
||||||
.rpt2_cache/
|
.rpt2_cache/
|
||||||
.rts2_cache_cjs/
|
.rts2_cache_cjs/
|
||||||
@@ -126,16 +236,26 @@ typings/
|
|||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env
|
.env
|
||||||
.env.test
|
.env.test
|
||||||
|
.env*.local
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
# Next.js build output
|
# Next.js build output
|
||||||
.next
|
.next
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
# Nuxt.js build / generate output
|
||||||
.nuxt
|
.nuxt
|
||||||
#dist
|
# dist
|
||||||
|
|
||||||
|
# Storybook build outputs
|
||||||
|
.out
|
||||||
|
.storybook-out
|
||||||
|
storybook-static
|
||||||
|
|
||||||
|
# rollup.js default build output
|
||||||
|
# dist/
|
||||||
|
|
||||||
# Gatsby files
|
# Gatsby files
|
||||||
.cache/
|
.cache/
|
||||||
@@ -161,6 +281,10 @@ typings/
|
|||||||
# Stores VSCode versions used for testing VSCode extensions
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
.vscode-test
|
.vscode-test
|
||||||
|
|
||||||
|
# Temporary folders
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
|
||||||
### Vim ###
|
### Vim ###
|
||||||
# Swap
|
# Swap
|
||||||
[._]*.s[a-v][a-z]
|
[._]*.s[a-v][a-z]
|
||||||
@@ -183,15 +307,14 @@ tags
|
|||||||
|
|
||||||
### VisualStudioCode ###
|
### VisualStudioCode ###
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
|
||||||
### VisualStudioCode Patch ###
|
### VisualStudioCode Patch ###
|
||||||
# Ignore all local history of files
|
# Ignore all local history of files
|
||||||
.history
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
### Windows ###
|
### Windows ###
|
||||||
# Windows thumbnail cache files
|
# Windows thumbnail cache files
|
||||||
@@ -222,16 +345,17 @@ $RECYCLE.BIN/
|
|||||||
### yarn ###
|
### yarn ###
|
||||||
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
|
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
|
||||||
|
|
||||||
# .yarn/unplugged and .yarn/build-state.yml should likely always be ignored since
|
.yarn/*
|
||||||
# they typically hold machine-specific build artifacts. Ignoring them might however
|
!.yarn/releases
|
||||||
# prevent Zero-Installs from working (to prevent this, set enableScripts to false).
|
!.yarn/plugins
|
||||||
.yarn/unplugged
|
!.yarn/sdks
|
||||||
.yarn/build-state.yml
|
!.yarn/versions
|
||||||
|
|
||||||
# .yarn/cache and .pnp.* may be safely ignored, but you'll need to run yarn install
|
# if you are NOT using Zero-installs, then:
|
||||||
# to regenerate them between each branch switch.
|
# comment the following lines
|
||||||
# Uncomment the following lines if you're not using Zero-Installs:
|
!.yarn/cache
|
||||||
# .yarn/cache
|
|
||||||
|
# and uncomment the following lines
|
||||||
# .pnp.*
|
# .pnp.*
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/vim,yarn,node,linux,macos,windows,visualstudiocode,composer
|
# End of https://www.toptal.com/developers/gitignore/api/vim,yarn,node,macos,linux,windows,composer,visualstudiocode,jetbrains
|
||||||
19
.prettierrc
Normal file
19
.prettierrc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
bracketSameLine: true
|
||||||
|
jsxBracketSameLine: true
|
||||||
|
jsxSingleQuote: true
|
||||||
|
printWidth: 100
|
||||||
|
proseWrap: "always"
|
||||||
|
semi: true
|
||||||
|
singleQuote: true
|
||||||
|
tabWidth: 4
|
||||||
|
trailingComma: "all"
|
||||||
|
useTabs: true
|
||||||
|
|
||||||
|
overrides:
|
||||||
|
- files:
|
||||||
|
- "*.json"
|
||||||
|
- "*.yml"
|
||||||
|
- "*.yaml"
|
||||||
|
options:
|
||||||
|
useTabs: false
|
||||||
|
tabWidth: 2
|
||||||
11
.vscode/extension.json
vendored
Normal file
11
.vscode/extension.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"bmewburn.vscode-intelephense-client",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"felixfbecker.php-debug",
|
||||||
|
"glowingblue.composer-package-name",
|
||||||
|
"firefox-devtools.vscode-firefox-debug"
|
||||||
|
]
|
||||||
|
}
|
||||||
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Attach to Flarum",
|
||||||
|
"type": "firefox",
|
||||||
|
"request": "attach",
|
||||||
|
"url": "http://localhost:8888",
|
||||||
|
"pathMappings": [
|
||||||
|
{
|
||||||
|
"url": "webpack://${command:glowingblue-composer-package-name.getName}/src/",
|
||||||
|
"path": "${workspaceFolder}/js/src/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
71
.vscode/settings.json
vendored
Normal file
71
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"editor.insertSpaces": false,
|
||||||
|
"editor.wordWrapColumn": 100,
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
"editor.detectIndentation": false,
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.insertSpaces": false
|
||||||
|
},
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"files.insertFinalNewline": true
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"files.insertFinalNewline": true
|
||||||
|
},
|
||||||
|
"[yaml]": {
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[html]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[css]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[less]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[scss]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[markdown]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[php]": {
|
||||||
|
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
|
||||||
|
"editor.insertSpaces": false
|
||||||
|
},
|
||||||
|
"files.associations": {
|
||||||
|
"*.html": "html",
|
||||||
|
"*.md": "markdown"
|
||||||
|
},
|
||||||
|
"prettier.bracketSameLine": true,
|
||||||
|
"prettier.jsxBracketSameLine": true,
|
||||||
|
"prettier.jsxSingleQuote": true,
|
||||||
|
"prettier.printWidth": 100,
|
||||||
|
"prettier.proseWrap": "always",
|
||||||
|
"prettier.semi": true,
|
||||||
|
"prettier.singleQuote": true,
|
||||||
|
"prettier.tabWidth": 4,
|
||||||
|
"prettier.trailingComma": "all",
|
||||||
|
"prettier.useTabs": true,
|
||||||
|
"js/ts.implicitProjectConfig.experimentalDecorators": true,
|
||||||
|
"eslint.packageManager": "yarn",
|
||||||
|
"remote.containers.workspaceMountConsistency": "consistent",
|
||||||
|
"remote.containers.defaultExtensions": [
|
||||||
|
"bmewburn.vscode-intelephense-client",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"xdebug.php-debug",
|
||||||
|
"firefox-devtools.vscode-firefox-debug"
|
||||||
|
]
|
||||||
|
}
|
||||||
17
LICENSE.md
17
LICENSE.md
@@ -1,7 +1,16 @@
|
|||||||
MIT License Copyright (c) 2021 Glowing Blue AG
|
MIT License Copyright (c) 2022 Glowing Blue AG
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||||
|
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
The above copyright notice and this permission notice (including the next paragraph) shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||||
|
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
||||||
|
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|||||||
34
README.md
34
README.md
@@ -1,24 +1,28 @@
|
|||||||
# ⚡️ Redis Setup
|
# ⚡️ Redis Setup
|
||||||
|
|
||||||
[](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md) [](https://packagist.org/packages/glowingblue/redis-setup) [](https://packagist.org/packages/glowingblue/redis-setup)
|
[](https://github.com/glowingblue/flarum-ext-redis-setup/blob/master/LICENSE.md)
|
||||||
|
[](https://packagist.org/packages/glowingblue/redis-setup)
|
||||||
|
[](https://packagist.org/packages/glowingblue/redis-setup)
|
||||||
|
|
||||||
A [Flarum](http://flarum.org) extension.
|
A [Flarum](http://flarum.org) extension.
|
||||||
|
|
||||||
Makes it easy to enable/disable Redis features:
|
Makes it easy to enable/disable Redis features:
|
||||||
|
|
||||||
- Cache
|
- Cache
|
||||||
- Queue
|
- Queue
|
||||||
- Sessions
|
- Sessions
|
||||||
|
|
||||||
For this to work, environment variables have to be set on your host:
|
If you are using a local redis setup, you will likely be able to simply use the defaults provided.
|
||||||
|
Any of these can be overridden using environment variables as follows:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
REDIS_HOST=null # Required
|
REDIS_HOST='127.0.0.1 # Optional, else uses default
|
||||||
REDIS_PORT=6379 # Optional, else uses default
|
REDIS_PORT=6379 # Optional, else uses default
|
||||||
REDIS_PASSWORD=null # Required, can be an empty string
|
REDIS_PASSWORD=null # Optional, otherwise null
|
||||||
REDIS_DATABASE_CACHE=1 # Optional, else uses default
|
REDIS_DATABASE_CACHE=1 # Optional, else uses default
|
||||||
REDIS_DATABASE_QUEUE=2 # Optional, else uses default
|
REDIS_DATABASE_QUEUE=2 # Optional, else uses default
|
||||||
REDIS_DATABASE_SESSION=3 # Optional, else uses default
|
REDIS_DATABASE_SESSION=3 # Optional, else uses default
|
||||||
|
REDIS_PREFIX='flarum_' # Optional, else uses default
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📥 Installation
|
## 📥 Installation
|
||||||
@@ -34,9 +38,17 @@ composer update glowingblue/redis-setup
|
|||||||
php flarum cache:clear
|
php flarum cache:clear
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compatibility with `fof/redis`
|
||||||
|
|
||||||
|
This extension depends on [`fof/redis`](https://github.com/FriendsOfFlarum/redis) and deliberately disables the **`settings` service** that `fof/redis` ≥ 1.1 provides.
|
||||||
|
|
||||||
|
`fof/redis`'s settings service replaces Flarum's `SettingsRepositoryInterface` with a Redis-backed caching layer. However, this extension reads settings (e.g. which Redis services to enable) during its own boot sequence — *before* Redis is fully wired into the container. Enabling the Redis settings cache here would create a circular dependency: configuring Redis requires reading settings, but reading settings requires Redis.
|
||||||
|
|
||||||
|
The `settings` service from `fof/redis` is therefore always disabled in this extension's extender. If you want Redis-backed settings caching, configure `fof/redis` directly in your project's root `extend.php` instead of using this extension.
|
||||||
|
|
||||||
## 🔗 Links
|
## 🔗 Links
|
||||||
|
|
||||||
- [Flarum Discuss post](https://discuss.flarum.org/d/27455)
|
- [Flarum Discuss post](https://discuss.flarum.org/d/27455)
|
||||||
- [Source code on GitHub](https://github.com/glowingblue/flarum-ext-redis-setup)
|
- [Source code on GitHub](https://github.com/glowingblue/flarum-ext-redis-setup)
|
||||||
- [Report an issue](https://github.com/glowingblue/flarum-ext-redis-setup/issues)
|
- [Report an issue](https://github.com/glowingblue/flarum-ext-redis-setup/issues)
|
||||||
- [Download via Packagist](https://packagist.org/packages/glowingblue/redis-setup)
|
- [Download via Packagist](https://packagist.org/packages/glowingblue/redis-setup)
|
||||||
|
|||||||
107
composer.json
107
composer.json
@@ -1,43 +1,74 @@
|
|||||||
{
|
{
|
||||||
"name": "glowingblue/redis-setup",
|
"name": "glowingblue/redis-setup",
|
||||||
"description": "Makes it easy to enable/disable Redis features: Cache, Queue & Sessions",
|
"description": "Makes it easy to enable/disable Redis features: Cache, Queue & Sessions",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"flarum", "redis", "cache", "queue", "session"
|
"flarum",
|
||||||
],
|
"redis",
|
||||||
"type": "flarum-extension",
|
"cache",
|
||||||
"license": "MIT",
|
"queue",
|
||||||
"support": {
|
"session"
|
||||||
"issues": "https://github.com/glowingblue/flarum-ext-redis-setup/issues",
|
],
|
||||||
"source": "https://github.com/glowingblue/flarum-ext-redis-setup",
|
"type": "flarum-extension",
|
||||||
"forum": "https://community.glowingblue.com/t/flarum-corner",
|
"license": "MIT",
|
||||||
"email": "dev@glowingblue.com"
|
"support": {
|
||||||
|
"issues": "https://github.com/glowingblue/flarum-ext-redis-setup/issues",
|
||||||
|
"source": "https://github.com/glowingblue/flarum-ext-redis-setup",
|
||||||
|
"forum": "https://community.glowingblue.com/t/flarum-corner",
|
||||||
|
"email": "dev@glowingblue.com"
|
||||||
|
},
|
||||||
|
"homepage": "https://glowingblue.com",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.1",
|
||||||
|
"flarum/core": "^1.8.5",
|
||||||
|
"fof/redis": "^1.1.4"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "IanM",
|
||||||
|
"homepage": "https://discuss.flarum.org/u/ianm",
|
||||||
|
"role": "Developer"
|
||||||
},
|
},
|
||||||
"homepage": "https://glowingblue.com",
|
{
|
||||||
"require": {
|
"name": "Glowing Blue AG",
|
||||||
"flarum/core": "^1.0.0",
|
"homepage": "https://glowingblue.com",
|
||||||
"blomstra/flarum-redis": "^0.4.0"
|
"role": "Developer"
|
||||||
},
|
},
|
||||||
"authors": [
|
{
|
||||||
{
|
"name": "Rafael Horvat",
|
||||||
"name": "IanM",
|
"role": "Developer"
|
||||||
"homepage": "https://discuss.flarum.org/u/ianm",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"GlowingBlue\\RedisSetup\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"flarum-extension": {
|
|
||||||
"title": "GB Redis Setup",
|
|
||||||
"category": "feature",
|
|
||||||
"icon": {
|
|
||||||
"name": "fas fa-tasks",
|
|
||||||
"backgroundColor": "#00a7e3",
|
|
||||||
"color": "#fff"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GlowingBlue\\RedisSetup\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"flarum-extension": {
|
||||||
|
"title": "GB Redis Setup",
|
||||||
|
"category": "feature",
|
||||||
|
"icon": {
|
||||||
|
"name": "fas fa-tasks",
|
||||||
|
"backgroundColor": "#00a7e3",
|
||||||
|
"color": "#fff"
|
||||||
|
},
|
||||||
|
"optional-dependencies": [
|
||||||
|
"fof/horizon"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extiverse": {
|
||||||
|
"discuss": "https://discuss.flarum.org/d/27455"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"flarum/phpstan": "*",
|
||||||
|
"fof/horizon": "^1.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"analyse:phpstan": "phpstan analyse",
|
||||||
|
"clear-cache:phpstan": "phpstan clear-result-cache"
|
||||||
|
},
|
||||||
|
"scripts-descriptions": {
|
||||||
|
"analyse:phpstan": "Run static analysis"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
extend.php
14
extend.php
@@ -3,7 +3,8 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of glowingblue/redis-setup.
|
* This file is part of glowingblue/redis-setup.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021 Ian Morland.
|
* Copyright (c) 2022 Glowing Blue AG.
|
||||||
|
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE.md
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -12,17 +13,18 @@
|
|||||||
namespace GlowingBlue\RedisSetup;
|
namespace GlowingBlue\RedisSetup;
|
||||||
|
|
||||||
use Flarum\Extend;
|
use Flarum\Extend;
|
||||||
use GlowingBlue\RedisSetup\Extend\EnableRedis;
|
use GlowingBlue\RedisSetup\Extend as GBExtend;
|
||||||
use GlowingBlue\RedisSetup\Provider\QueueProvider;
|
use GlowingBlue\RedisSetup\Provider\QueueProvider;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new Extend\Frontend('admin'))
|
(new Extend\Frontend('admin'))
|
||||||
->js(__DIR__.'/js/dist/admin.js'),
|
->js(__DIR__ . '/js/dist/admin.js'),
|
||||||
|
|
||||||
new Extend\Locales(__DIR__.'/resources/locale'),
|
new Extend\Locales(__DIR__ . '/resources/locale'),
|
||||||
|
|
||||||
|
new GBExtend\ConfigureHorizon(),
|
||||||
|
new GBExtend\EnableRedis(),
|
||||||
|
|
||||||
(new Extend\ServiceProvider())
|
(new Extend\ServiceProvider())
|
||||||
->register(QueueProvider::class),
|
->register(QueueProvider::class),
|
||||||
|
|
||||||
new EnableRedis()
|
|
||||||
];
|
];
|
||||||
|
|||||||
2
js/dist/admin.js
vendored
2
js/dist/admin.js
vendored
@@ -1,2 +1,2 @@
|
|||||||
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=flarum.core.compat["admin/app"]},function(e,t){e.exports=flarum.core.compat["common/extend"]},function(e,t){e.exports=flarum.core.compat["admin/components/StatusWidget"]},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(1),i=n(2),u=n.n(i);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o.a.initializers.add("glowingblue-redis-setup",(function(){o.a.extensionData.for("glowingblue-redis-setup").registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:o.a.translator.trans("glowingblue-redis-setup.admin.settings.enable_queue")}),Object(a.extend)(u.a.prototype,"items",(function(e){var t=o.a.data.blomstraQueuesLoad;if(void 0!==t)for(var n,r=l(o.a.data.blomstraQueuesSeen);!(n=r()).done;){var a=n.value,i=t[a]||null;e.add("blomstra-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))}]);
|
(()=>{var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const r=flarum.core.compat["admin/app"];var n=e.n(r);const o=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/components/StatusWidget"];var i=e.n(a),l="glowingblue-redis-setup";function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var u=n().translator.trans.bind(n().translator),d=l+".admin.settings";n().initializers.add(l,(function(){n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:u(d+".enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:u(d+".enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:u(d+".enable_queue")}),n().initializers.has("fof/horizon")&&n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.horizonConfig",type:"textarea",label:u(d+".horizon_config"),help:u(d+".horizon_help_text")}),(0,o.extend)(i().prototype,"items",(function(e){var t=n().data.fofQueuesLoad;if(void 0!==t)for(var r,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n().data.fofQueuesSeen);!(r=o()).done;){var a=r.value,i=t[a]||null;e.add("fof-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))})(),module.exports=t})();
|
||||||
//# sourceMappingURL=admin.js.map
|
//# sourceMappingURL=admin.js.map
|
||||||
2
js/dist/admin.js.map
vendored
2
js/dist/admin.js.map
vendored
File diff suppressed because one or more lines are too long
4953
js/package-lock.json
generated
4953
js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "@glowingblue/redis-setup",
|
"name": "@glowingblue/redis-setup",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"prettier": "@glowingblue-dev/prettier-config",
|
||||||
"flarum-webpack-config": "^0.1.0-beta.10",
|
"dependencies": {
|
||||||
"webpack": "^4.26.0",
|
"flarum-webpack-config": "^2.0.0",
|
||||||
"webpack-cli": "^3.0.7"
|
"webpack": "^5.72.0",
|
||||||
},
|
"webpack-cli": "^5.0"
|
||||||
"scripts": {
|
},
|
||||||
"dev": "webpack --mode development --watch",
|
"devDependencies": {
|
||||||
"build": "webpack --mode production",
|
"@glowingblue-dev/prettier-config": "^1.0.0",
|
||||||
"lint": "prettier --single-quote --jsx-single-quote --trailing-comma es5 --print-width 100 --use-tabs --tab-width 4 --write src"
|
"prettier": "^3.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"scripts": {
|
||||||
"prettier": "^2.3.0"
|
"dev": "webpack --mode development --watch",
|
||||||
}
|
"build": "webpack --mode production",
|
||||||
|
"format": "prettier --write src",
|
||||||
|
"format-check": "prettier --check src"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import app from 'flarum/admin/app';
|
|
||||||
import { extend } from 'flarum/common/extend';
|
|
||||||
import StatusWidget from 'flarum/admin/components/StatusWidget';
|
|
||||||
|
|
||||||
app.initializers.add('glowingblue-redis-setup', () => {
|
|
||||||
app.extensionData
|
|
||||||
.for('glowingblue-redis-setup')
|
|
||||||
.registerSetting({
|
|
||||||
setting: 'glowingblue-redis.enableCache',
|
|
||||||
type: 'boolean',
|
|
||||||
label: app.translator.trans('glowingblue-redis-setup.admin.settings.enable_cache'),
|
|
||||||
})
|
|
||||||
.registerSetting({
|
|
||||||
setting: 'glowingblue-redis.redisSessions',
|
|
||||||
type: 'boolean',
|
|
||||||
label: app.translator.trans(
|
|
||||||
'glowingblue-redis-setup.admin.settings.enable_redis_sessions'
|
|
||||||
),
|
|
||||||
})
|
|
||||||
.registerSetting({
|
|
||||||
setting: 'glowingblue-redis.enableQueue',
|
|
||||||
type: 'boolean',
|
|
||||||
label: app.translator.trans('glowingblue-redis-setup.admin.settings.enable_queue'),
|
|
||||||
});
|
|
||||||
|
|
||||||
extend(StatusWidget.prototype, 'items', (items) => {
|
|
||||||
const loads = app.data.blomstraQueuesLoad;
|
|
||||||
|
|
||||||
if (loads === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let queue of app.data.blomstraQueuesSeen) {
|
|
||||||
const load = loads[queue] || null;
|
|
||||||
items.add('blomstra-queue-size-' + queue, [
|
|
||||||
<strong>Queue {queue}</strong>,
|
|
||||||
<br />,
|
|
||||||
load || '0',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
65
js/src/admin/index.tsx
Normal file
65
js/src/admin/index.tsx
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of glowingblue/redis-setup.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Glowing Blue AG.
|
||||||
|
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import app from 'flarum/admin/app';
|
||||||
|
import { extend } from 'flarum/common/extend';
|
||||||
|
import StatusWidget from 'flarum/admin/components/StatusWidget';
|
||||||
|
import { slug } from '../common';
|
||||||
|
|
||||||
|
// Make translation calls shorter
|
||||||
|
const t = app.translator.trans.bind(app.translator);
|
||||||
|
const prfx = `${slug}.admin.settings`;
|
||||||
|
|
||||||
|
app.initializers.add(slug, () => {
|
||||||
|
app.extensionData
|
||||||
|
.for(slug)
|
||||||
|
.registerSetting({
|
||||||
|
setting: 'glowingblue-redis.enableCache',
|
||||||
|
type: 'boolean',
|
||||||
|
label: t(`${prfx}.enable_cache`),
|
||||||
|
})
|
||||||
|
.registerSetting({
|
||||||
|
setting: 'glowingblue-redis.redisSessions',
|
||||||
|
type: 'boolean',
|
||||||
|
label: t(`${prfx}.enable_redis_sessions`),
|
||||||
|
})
|
||||||
|
.registerSetting({
|
||||||
|
setting: 'glowingblue-redis.enableQueue',
|
||||||
|
type: 'boolean',
|
||||||
|
label: t(`${prfx}.enable_queue`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (app.initializers.has('fof/horizon')) {
|
||||||
|
app.extensionData.for(slug).registerSetting({
|
||||||
|
setting: 'glowingblue-redis.horizonConfig',
|
||||||
|
type: 'textarea',
|
||||||
|
label: t(`${prfx}.horizon_config`),
|
||||||
|
help: t(`${prfx}.horizon_help_text`),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
extend(StatusWidget.prototype, 'items', (items) => {
|
||||||
|
const loads = app.data.fofQueuesLoad;
|
||||||
|
|
||||||
|
if (loads === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
for (let queue of app.data.fofQueuesSeen) {
|
||||||
|
const load = loads[queue] || null;
|
||||||
|
items.add('fof-queue-size-' + queue, [
|
||||||
|
<strong>Queue {queue}</strong>,
|
||||||
|
<br />,
|
||||||
|
load || '0',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
11
js/src/common/index.ts
Normal file
11
js/src/common/index.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of glowingblue/redis-setup.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Glowing Blue AG.
|
||||||
|
* Authors: Rafael Horvat.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const slug = 'glowingblue-redis-setup';
|
||||||
17
js/tsconfig.json
Normal file
17
js/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
// Use Flarum's tsconfig as a starting point
|
||||||
|
"extends": "flarum-tsconfig",
|
||||||
|
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
|
||||||
|
// and also tells your Typescript server to read core's global typings for
|
||||||
|
// access to `dayjs` and `$` in the global namespace.
|
||||||
|
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
// This will output typings to `dist-typings`
|
||||||
|
"declarationDir": "./dist-typings",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
2291
js/yarn.lock
Normal file
2291
js/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
13
phpstan.neon
Normal file
13
phpstan.neon
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
includes:
|
||||||
|
- vendor/flarum/phpstan/extension.neon
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
# The level will be increased in Flarum 2.0
|
||||||
|
level: 5
|
||||||
|
paths:
|
||||||
|
- extend.php
|
||||||
|
- src
|
||||||
|
excludePaths:
|
||||||
|
- *.blade.php
|
||||||
|
checkMissingIterableValueType: false
|
||||||
|
databaseMigrationsPath: ['migrations']
|
||||||
@@ -2,5 +2,8 @@ glowingblue-redis-setup:
|
|||||||
admin:
|
admin:
|
||||||
settings:
|
settings:
|
||||||
enable_cache: Enable Redis cache
|
enable_cache: Enable Redis cache
|
||||||
enable_redis_sessions: Enable Redis sessions (all users will be logged out after changing this setting)
|
enable_redis_sessions:
|
||||||
|
Enable Redis sessions (all users will be logged out after changing this setting)
|
||||||
enable_queue: Enable Redis queue
|
enable_queue: Enable Redis queue
|
||||||
|
horizon_config: "Horizon config (format: JSON)."
|
||||||
|
horizon_help_text: This will be passed to <code>(new \FoF\Horizon\Extend\Horizon)->config(...))</code>
|
||||||
|
|||||||
45
src/Extend/ConfigureHorizon.php
Normal file
45
src/Extend/ConfigureHorizon.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of glowingblue/redis-setup.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Glowing Blue AG.
|
||||||
|
* Authors: Rafael Horvat.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace GlowingBlue\RedisSetup\Extend;
|
||||||
|
|
||||||
|
use FoF\Horizon\Extend\Horizon;
|
||||||
|
use Flarum\Extend\ExtenderInterface;
|
||||||
|
use Flarum\Extension\Extension;
|
||||||
|
use Flarum\Extension\ExtensionManager;
|
||||||
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
|
||||||
|
class ConfigureHorizon implements ExtenderInterface
|
||||||
|
{
|
||||||
|
public function extend(Container $container, Extension $extension = null)
|
||||||
|
{
|
||||||
|
$extensions = resolve(ExtensionManager::class);
|
||||||
|
|
||||||
|
if (!$extensions->isEnabled('fof-horizon') || !class_exists(Horizon::class)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var SettingsRepositoryInterface */
|
||||||
|
$settings = resolve(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
|
$config = json_decode($settings->get('glowingblue-redis.horizonConfig', '[]'), true);
|
||||||
|
|
||||||
|
if (!is_array($config) || empty($config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(new Horizon())
|
||||||
|
->config($config)
|
||||||
|
->extend($container, $extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of glowingblue/redis-setup.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Glowing Blue AG.
|
||||||
|
* Authors: Ian Morland, iPurpl3x, Rafael Horvat.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace GlowingBlue\RedisSetup\Extend;
|
namespace GlowingBlue\RedisSetup\Extend;
|
||||||
|
|
||||||
use Blomstra\Redis\Extend\Redis;
|
use FoF\Redis\Extend\Redis;
|
||||||
use Flarum\Extend\ExtenderInterface;
|
use Flarum\Extend\ExtenderInterface;
|
||||||
use Flarum\Extension\Extension;
|
use Flarum\Extension\Extension;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
@@ -11,104 +21,109 @@ use Illuminate\Support\Arr;
|
|||||||
|
|
||||||
class EnableRedis implements ExtenderInterface
|
class EnableRedis implements ExtenderInterface
|
||||||
{
|
{
|
||||||
const CACHE_KEY = 'connections.cache';
|
const CACHE_KEY = 'connections.cache';
|
||||||
const QUEUE_KEY = 'connections.queue';
|
const QUEUE_KEY = 'connections.queue';
|
||||||
const SESSION_KEY = 'connections.session';
|
const SESSION_KEY = 'connections.session';
|
||||||
|
|
||||||
public function extend(Container $container, Extension $extension = null)
|
public function extend(Container $container, Extension $extension = null)
|
||||||
{
|
{
|
||||||
$config = $this->buildConfig();
|
$config = $this->buildConfig();
|
||||||
|
|
||||||
if (Arr::hasAny($config, [self::CACHE_KEY, self::QUEUE_KEY, self::SESSION_KEY])) {
|
/** @var Redis $redis */
|
||||||
(new Redis($config))->disable($this->getDisabledServices())->extend($container, $extension);
|
$redis = (new Redis($config))
|
||||||
}
|
->disable(['settings', ...$this->getDisabledServices()]);
|
||||||
}
|
|
||||||
|
|
||||||
private function getDisabledServices(): array
|
$redis->extend($container, $extension);
|
||||||
{
|
}
|
||||||
/** @var SettingsRepositoryInterface */
|
|
||||||
$settings = resolve(SettingsRepositoryInterface::class);
|
|
||||||
|
|
||||||
$disabled = [];
|
private function getDisabledServices(): array
|
||||||
|
{
|
||||||
|
/** @var SettingsRepositoryInterface */
|
||||||
|
$settings = resolve(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
if (!(bool) $settings->get('glowingblue-redis.enableCache', false)) {
|
$disabled = [];
|
||||||
$disabled[] = 'cache';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(bool) $settings->get('glowingblue-redis.enableQueue', false)) {
|
if (!(bool) $settings->get('glowingblue-redis.enableCache', false)) {
|
||||||
$disabled[] = 'queue';
|
$disabled[] = 'cache';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(bool) $settings->get('glowingblue-redis.redisSessions', false)) {
|
if (!(bool) $settings->get('glowingblue-redis.enableQueue', false)) {
|
||||||
$disabled[] = 'session';
|
$disabled[] = 'queue';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $disabled;
|
if (!(bool) $settings->get('glowingblue-redis.redisSessions', false)) {
|
||||||
}
|
$disabled[] = 'session';
|
||||||
|
}
|
||||||
|
|
||||||
private function buildConfig(): array
|
return $disabled;
|
||||||
{
|
}
|
||||||
if ($this->getHost() === null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = [];
|
private function buildConfig($config = []): array
|
||||||
|
{
|
||||||
|
$base = [
|
||||||
|
'host' => $this->getHost(),
|
||||||
|
'password' => $this->getPassword(),
|
||||||
|
'port' => $this->getPort(),
|
||||||
|
'prefix' => $this->getPrefix(),
|
||||||
|
];
|
||||||
|
|
||||||
$cache = [
|
$cache = $base + [
|
||||||
'host' => $this->getHost(),
|
'database' => static::getCacheDatabase(),
|
||||||
'password' => $this->getPassword(),
|
];
|
||||||
'port' => $this->getPort(),
|
|
||||||
'database' => $this->getCacheDatabase(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$queue = [
|
$queue = $base + [
|
||||||
'host' => $this->getHost(),
|
'database' => static::getQueueDatabase(),
|
||||||
'password' => $this->getPassword(),
|
];
|
||||||
'port' => $this->getPort(),
|
|
||||||
'database' => $this->getQueueDatabase(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$session = [
|
$session = $base + [
|
||||||
'host' => $this->getHost(),
|
'database' => static::getSessionDatabase(),
|
||||||
'password' => $this->getPassword(),
|
];
|
||||||
'port' => $this->getPort(),
|
|
||||||
'database' => $this->getSessionDatabase(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$config = Arr::add($config, self::CACHE_KEY, $cache);
|
$config = Arr::add($config, self::CACHE_KEY, $cache);
|
||||||
$config = Arr::add($config, self::QUEUE_KEY, $queue);
|
$config = Arr::add($config, self::QUEUE_KEY, $queue);
|
||||||
$config = Arr::add($config, self::SESSION_KEY, $session);
|
$config = Arr::add($config, self::SESSION_KEY, $session);
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHost(): ?string
|
public static function getHost(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : null;
|
return getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPassword(): ?string
|
public static function getPassword(): ?string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_PASSWORD') ? getenv('REDIS_PASSWORD') : null;
|
return getenv('REDIS_PASSWORD') ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPort(): string
|
public static function getPort(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_PORT') ? getenv('REDIS_PORT') : '6379';
|
return getenv('REDIS_PORT') ?: '6379';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCacheDatabase(): int
|
public static function getCacheDatabase(): int
|
||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_CACHE') ? getenv('REDIS_DATABASE_CACHE') : 1;
|
$val = getenv('REDIS_DATABASE_CACHE');
|
||||||
}
|
|
||||||
|
|
||||||
private function getQueueDatabase(): int
|
return $val !== false ? (int) $val : 1;
|
||||||
{
|
}
|
||||||
return (int) getenv('REDIS_DATABASE_QUEUE') ? getenv('REDIS_DATABASE_QUEUE') : 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getSessionDatabase(): int
|
public static function getQueueDatabase(): int
|
||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
|
$val = getenv('REDIS_DATABASE_QUEUE');
|
||||||
}
|
|
||||||
|
return $val !== false ? (int) $val : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSessionDatabase(): int
|
||||||
|
{
|
||||||
|
$val = getenv('REDIS_DATABASE_SESSION');
|
||||||
|
|
||||||
|
return $val !== false ? (int) $val : 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPrefix(): string
|
||||||
|
{
|
||||||
|
return getenv('REDIS_PREFIX') ?: 'flarum_';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of glowingblue/redis-setup.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Glowing Blue AG.
|
||||||
|
* Authors: iPurpl3x, Ian Morland, Rafael Horvat.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace GlowingBlue\RedisSetup\Provider;
|
namespace GlowingBlue\RedisSetup\Provider;
|
||||||
|
|
||||||
use Flarum\Extend\Frontend;
|
use Flarum\Extend\Frontend;
|
||||||
@@ -15,59 +25,59 @@ use Illuminate\Contracts\Queue\Queue as QueueContract;
|
|||||||
|
|
||||||
class QueueProvider extends AbstractServiceProvider
|
class QueueProvider extends AbstractServiceProvider
|
||||||
{
|
{
|
||||||
private $connection = 'default';
|
private $connection = 'default';
|
||||||
|
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
/** @var SettingsRepositoryInterface */
|
/** @var SettingsRepositoryInterface */
|
||||||
$settings = resolve(SettingsRepositoryInterface::class);
|
$settings = resolve(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
if (!(bool) $settings->get('glowingblue-redis.enableQueue', false)) {
|
if (!(bool) $settings->get('glowingblue-redis.enableQueue', false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ExtensionManager $extensions */
|
/** @var ExtensionManager $extensions */
|
||||||
$extensions = resolve(ExtensionManager::class);
|
$extensions = resolve(ExtensionManager::class);
|
||||||
|
|
||||||
(new Frontend('admin'))
|
(new Frontend('admin'))
|
||||||
->content([$this, 'adminWidgetAttributes'])
|
->content([$this, 'adminWidgetAttributes'])
|
||||||
->extend($this->container, $extensions->getExtension('glowingblue-redis-setup'));
|
->extend($this->container, $extensions->getExtension('glowingblue-redis-setup'));
|
||||||
|
|
||||||
/** @var Dispatcher $dispatcher */
|
/** @var Dispatcher $dispatcher */
|
||||||
$dispatcher = $this->container->make(Dispatcher::class);
|
$dispatcher = $this->container->make(Dispatcher::class);
|
||||||
$dispatcher->listen(Looping::class, [$this, 'trackQueues']);
|
$dispatcher->listen(Looping::class, [$this, 'trackQueues']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adminWidgetAttributes(Document $document)
|
public function adminWidgetAttributes(Document $document)
|
||||||
{
|
{
|
||||||
/** @var Store $cache */
|
/** @var Store $cache */
|
||||||
$cache = resolve('cache.store');
|
$cache = resolve('cache.store');
|
||||||
/** @var QueueContract $queue */
|
/** @var QueueContract $queue */
|
||||||
$queue = resolve(QueueContract::class);
|
$queue = resolve(QueueContract::class);
|
||||||
|
|
||||||
$queues = $cache->get('blomstra.queue.queues-seen') ?? [];
|
$queues = $cache->get('fof.queue.queues-seen') ?? [];
|
||||||
|
|
||||||
if ($queue instanceof RedisQueue) {
|
if ($queue instanceof RedisQueue) {
|
||||||
$load = [];
|
$load = [];
|
||||||
|
|
||||||
foreach ($queues as $name) {
|
foreach ($queues as $name) {
|
||||||
$load[$name] = $queue->getRedis()
|
$load[$name] = $queue->getRedis()
|
||||||
->connection($this->connection)
|
->connection($this->connection)
|
||||||
->llen('queues:' . $name);
|
->llen('queues:' . $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$document->payload['blomstraQueuesSeen'] = $queues;
|
$document->payload['fofQueuesSeen'] = $queues;
|
||||||
$document->payload['blomstraQueuesLoad'] = $load ?? null;
|
$document->payload['fofQueuesLoad'] = $load ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function trackQueues(Looping $event)
|
public function trackQueues(Looping $event)
|
||||||
{
|
{
|
||||||
/** @var Store $cache */
|
/** @var Store $cache */
|
||||||
$cache = resolve('cache.store');
|
$cache = resolve('cache.store');
|
||||||
|
|
||||||
$queues = $cache->get('blomstra.queue.queues-seen') ?? [];
|
$queues = $cache->get('fof.queue.queues-seen') ?? [];
|
||||||
$queues = array_merge($queues, (array) explode(',', $event->queue));
|
$queues = array_merge($queues, (array) explode(',', $event->queue));
|
||||||
$cache->put('blomstra.queue.queues-seen', array_unique($queues), 60);
|
$cache->put('fof.queue.queues-seen', array_unique($queues), 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user