-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'init-caches' into merge-queue-attempt-1
- Loading branch information
Showing
15 changed files
with
443 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
defmodule Teiserver.Account.PermissionCache do | ||
@moduledoc """ | ||
Define caches and set them up for permission related things | ||
""" | ||
|
||
use Supervisor | ||
import Teiserver.Account.AuthLib, only: [add_permission_set: 3] | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts), | ||
:ok <- warm_permission_cache() do | ||
warm_restriction_cache() | ||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:auth_group_store), | ||
CacheHelper.concache_perm_sup(:restriction_lookup_store) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_all) | ||
end | ||
|
||
defp warm_permission_cache() do | ||
add_permission_set("admin", "debug", ~w(debug)) | ||
add_permission_set("admin", "dev", ~w(developer structure)) | ||
add_permission_set("admin", "admin", ~w(limited full)) | ||
add_permission_set("admin", "report", ~w(show update delete report)) | ||
add_permission_set("admin", "user", ~w(show create update delete report)) | ||
add_permission_set("admin", "group", ~w(show create update delete report config)) | ||
add_permission_set("teiserver", "admin", ~w(account battle clan queue)) | ||
|
||
add_permission_set( | ||
"teiserver", | ||
"staff", | ||
~w(overwatch reviewer moderator admin communication clan telemetry server) | ||
) | ||
|
||
add_permission_set("teiserver", "dev", ~w(infolog)) | ||
add_permission_set("teiserver", "reports", ~w(client server match ratings infolog)) | ||
add_permission_set("teiserver", "api", ~w(battle)) | ||
|
||
add_permission_set( | ||
"teiserver", | ||
"player", | ||
~w(account tester contributor dev streamer donor verified bot moderator) | ||
) | ||
|
||
:ok = Teiserver.Logging.Startup.startup() | ||
|
||
:ok | ||
end | ||
|
||
defp warm_restriction_cache() do | ||
# Chat stuff | ||
Teiserver.Account.UserLib.add_report_restriction_types("Chat", [ | ||
"Bridging", | ||
"Game chat", | ||
"Room chat", | ||
"All chat" | ||
]) | ||
|
||
# Lobby interaction | ||
Teiserver.Account.UserLib.add_report_restriction_types("Game", [ | ||
"Low priority", | ||
"All lobbies", | ||
"Login", | ||
"Permanently banned" | ||
]) | ||
|
||
Teiserver.Account.UserLib.add_report_restriction_types("Other", [ | ||
"Accolades", | ||
"Boss", | ||
"Reporting", | ||
"Renaming", | ||
"Matchmaking" | ||
]) | ||
|
||
Teiserver.Account.UserLib.add_report_restriction_types("Warnings", [ | ||
"Warning reminder" | ||
]) | ||
|
||
Teiserver.Account.UserLib.add_report_restriction_types("Internal", [ | ||
"Note" | ||
]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Teiserver.Communication.Cache do | ||
@moduledoc """ | ||
Cache and setup for communication stuff | ||
""" | ||
|
||
use Supervisor | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts), | ||
:ok <- Teiserver.Communication.build_text_callback_cache() do | ||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:text_callback_trigger_lookup), | ||
CacheHelper.concache_perm_sup(:text_callback_store) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_all) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule Teiserver.Config.SiteConfigTypes.Cache do | ||
@moduledoc """ | ||
Cache and setup for site configuration | ||
""" | ||
|
||
use Supervisor | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts), | ||
:ok <- Teiserver.Config.SiteConfigTypes.SystemConfigs.create(), | ||
:ok <- Teiserver.TeiserverConfigs.teiserver_configs() do | ||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:config_site_type_store), | ||
CacheHelper.concache_perm_sup(:config_site_cache) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_all) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Teiserver.Config.UserConfigTypes.Cache do | ||
@moduledoc """ | ||
Cache and setup for profile configuration | ||
""" | ||
|
||
use Supervisor | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts), | ||
:ok <- Teiserver.Config.UserConfigTypes.ProfileConfigs.create(), | ||
:ok <- Teiserver.Config.UserConfigTypes.PrivacyConfigs.create() do | ||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:config_user_type_store) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_one) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule Teiserver.Data.MatchmakingCache do | ||
@moduledoc """ | ||
Define cache for matchmaking and set it up | ||
""" | ||
|
||
use Supervisor | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts) do | ||
Teiserver.cache_put(:lists, :rooms, []) | ||
Teiserver.cache_put(:lists, :lobby_policies, []) | ||
Teiserver.Data.Matchmaking.pre_cache_queues() | ||
|
||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:teiserver_queues), | ||
CacheHelper.concache_perm_sup(:lists) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_all) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule Teiserver.Data.LobbyPolicyCache do | ||
@moduledoc """ | ||
Define cache for lobby policies and set it up | ||
""" | ||
|
||
use Supervisor | ||
alias Teiserver.Helpers.CacheHelper | ||
|
||
def start_link(opts) do | ||
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts) do | ||
Teiserver.Game.pre_cache_policies() | ||
{:ok, sup} | ||
end | ||
end | ||
|
||
@impl true | ||
def init(:ok) do | ||
children = [ | ||
CacheHelper.concache_perm_sup(:lobby_policies_cache) | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_one) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.