mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Split table definitions from db configuration.
This commit is contained in:
@@ -183,48 +183,67 @@ hardcache_categories = *:hc:hc
|
||||
db_app_name = reddit
|
||||
# are we allowed to create tables?
|
||||
db_create_tables = True
|
||||
# are we allowed to write at all?
|
||||
disallow_db_writes = False
|
||||
|
||||
type_db = main
|
||||
rel_type_db = main
|
||||
hardcache_db = main
|
||||
|
||||
db_table_link = thing, main, main
|
||||
db_table_account = thing, main
|
||||
db_table_message = thing, main
|
||||
# definitions of what each table is (probably shouldn't change in .update files)
|
||||
# things require no extra info. relation is followed by the names of the related tables
|
||||
db_table_link = thing
|
||||
db_table_account = thing
|
||||
db_table_message = thing
|
||||
db_table_savehide = relation, account, link
|
||||
db_table_click = relation, account, link
|
||||
db_table_comment = thing
|
||||
db_table_subreddit = thing
|
||||
db_table_srmember = relation, subreddit, account
|
||||
db_table_friend = relation, account, account
|
||||
db_table_vote_account_link = relation, account, link
|
||||
db_table_vote_account_comment = relation, account, comment
|
||||
db_table_inbox_account_comment = relation, account, comment
|
||||
db_table_inbox_account_message = relation, account, message
|
||||
db_table_moderatorinbox = relation, subreddit, message
|
||||
db_table_report_account_link = relation, account, link
|
||||
db_table_report_account_comment = relation, account, comment
|
||||
db_table_report_account_message = relation, account, message
|
||||
db_table_report_account_subreddit = relation, account, subreddit
|
||||
db_table_award = thing
|
||||
db_table_trophy = relation, account, award
|
||||
db_table_jury_account_link = relation, account, link
|
||||
db_table_ad = thing
|
||||
db_table_adsr = relation, ad, subreddit
|
||||
db_table_flair = relation, subreddit, account
|
||||
|
||||
db_table_savehide = relation, account, link, main
|
||||
db_table_click = relation, account, link, main
|
||||
|
||||
db_table_comment = thing, comment
|
||||
db_table_subreddit = thing, comment
|
||||
|
||||
db_table_srmember = relation, subreddit, account, comment
|
||||
|
||||
db_table_friend = relation, account, account, comment
|
||||
|
||||
db_table_vote_account_link = relation, account, link, vote
|
||||
db_table_vote_account_comment = relation, account, comment, vote
|
||||
|
||||
db_table_inbox_account_comment = relation, account, comment, main
|
||||
db_table_inbox_account_message = relation, account, message, main
|
||||
db_table_moderatorinbox = relation, subreddit, message, main
|
||||
|
||||
db_table_report_account_link = relation, account, link, main
|
||||
db_table_report_account_comment = relation, account, comment, comment
|
||||
db_table_report_account_message = relation, account, message, main
|
||||
db_table_report_account_subreddit = relation, account, subreddit, main
|
||||
|
||||
db_table_award = thing, award
|
||||
db_table_trophy = relation, account, award, award
|
||||
|
||||
db_table_jury_account_link = relation, account, link, main
|
||||
|
||||
db_table_ad = thing, main
|
||||
db_table_adsr = relation, ad, subreddit, main
|
||||
|
||||
db_table_flair = relation, subreddit, account, main
|
||||
|
||||
disallow_db_writes = False
|
||||
# which servers to find each table on (likely to change in .update files)
|
||||
# first server listed is assumed to be the master, all others are read-only slaves
|
||||
# additionally, a "!avoid_master" flag may be added to specify that reads should use the slaves
|
||||
db_servers_link = main, main
|
||||
db_servers_account = main
|
||||
db_servers_message = main
|
||||
db_servers_savehide = main
|
||||
db_servers_click = main
|
||||
db_servers_comment = comment
|
||||
db_servers_subreddit = comment
|
||||
db_servers_srmember = comment
|
||||
db_servers_friend = comment
|
||||
db_servers_vote_account_link = vote
|
||||
db_servers_vote_account_comment = vote
|
||||
db_servers_inbox_account_comment = main
|
||||
db_servers_inbox_account_message = main
|
||||
db_servers_moderatorinbox = main
|
||||
db_servers_report_account_link = main
|
||||
db_servers_report_account_comment = comment
|
||||
db_servers_report_account_message = main
|
||||
db_servers_report_account_subreddit = main
|
||||
db_servers_award = award
|
||||
db_servers_trophy = award
|
||||
db_servers_jury_account_link = main
|
||||
db_servers_ad = main
|
||||
db_servers_adsr = main
|
||||
db_servers_flair = main
|
||||
|
||||
|
||||
## -- traffic analytics --
|
||||
|
||||
@@ -487,19 +487,22 @@ class Globals(object):
|
||||
|
||||
prefix = 'db_table_'
|
||||
for k, v in self.config.raw_data.iteritems():
|
||||
if k.startswith(prefix):
|
||||
params = list(ConfigValue.to_iter(v))
|
||||
name = k[len(prefix):]
|
||||
kind = params[0]
|
||||
if kind == 'thing':
|
||||
engines, flags = split_flags(params[1:])
|
||||
dbm.add_thing(name, dbm.get_engines(engines),
|
||||
**flags)
|
||||
elif kind == 'relation':
|
||||
engines, flags = split_flags(params[3:])
|
||||
dbm.add_relation(name, params[1], params[2],
|
||||
dbm.get_engines(engines),
|
||||
**flags)
|
||||
if not k.startswith(prefix):
|
||||
continue
|
||||
|
||||
params = tuple(ConfigValue.to_iter(v))
|
||||
name = k[len(prefix):]
|
||||
kind = params[0]
|
||||
server_list = self.config.raw_data["db_servers_" + name]
|
||||
engines, flags = split_flags(ConfigValue.to_iter(server_list))
|
||||
|
||||
if kind == 'thing':
|
||||
dbm.add_thing(name, dbm.get_engines(engines),
|
||||
**flags)
|
||||
elif kind == 'relation':
|
||||
dbm.add_relation(name, params[1], params[2],
|
||||
dbm.get_engines(engines),
|
||||
**flags)
|
||||
return dbm
|
||||
|
||||
def __del__(self):
|
||||
|
||||
Reference in New Issue
Block a user