summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/hashserv/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/hashserv/__init__.py')
-rw-r--r--bitbake/lib/hashserv/__init__.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/bitbake/lib/hashserv/__init__.py b/bitbake/lib/hashserv/__init__.py
index 622ca17a91..55f48410d3 100644
--- a/bitbake/lib/hashserv/__init__.py
+++ b/bitbake/lib/hashserv/__init__.py
@@ -22,6 +22,24 @@ ADDR_TYPE_TCP = 1
22# is necessary 22# is necessary
23DEFAULT_MAX_CHUNK = 32 * 1024 23DEFAULT_MAX_CHUNK = 32 * 1024
24 24
25TABLE_DEFINITION = (
26 ("method", "TEXT NOT NULL"),
27 ("outhash", "TEXT NOT NULL"),
28 ("taskhash", "TEXT NOT NULL"),
29 ("unihash", "TEXT NOT NULL"),
30 ("created", "DATETIME"),
31
32 # Optional fields
33 ("owner", "TEXT"),
34 ("PN", "TEXT"),
35 ("PV", "TEXT"),
36 ("PR", "TEXT"),
37 ("task", "TEXT"),
38 ("outhash_siginfo", "TEXT"),
39)
40
41TABLE_COLUMNS = tuple(name for name, _ in TABLE_DEFINITION)
42
25def setup_database(database, sync=True): 43def setup_database(database, sync=True):
26 db = sqlite3.connect(database) 44 db = sqlite3.connect(database)
27 db.row_factory = sqlite3.Row 45 db.row_factory = sqlite3.Row
@@ -30,23 +48,10 @@ def setup_database(database, sync=True):
30 cursor.execute(''' 48 cursor.execute('''
31 CREATE TABLE IF NOT EXISTS tasks_v2 ( 49 CREATE TABLE IF NOT EXISTS tasks_v2 (
32 id INTEGER PRIMARY KEY AUTOINCREMENT, 50 id INTEGER PRIMARY KEY AUTOINCREMENT,
33 method TEXT NOT NULL, 51 %s
34 outhash TEXT NOT NULL,
35 taskhash TEXT NOT NULL,
36 unihash TEXT NOT NULL,
37 created DATETIME,
38
39 -- Optional fields
40 owner TEXT,
41 PN TEXT,
42 PV TEXT,
43 PR TEXT,
44 task TEXT,
45 outhash_siginfo TEXT,
46
47 UNIQUE(method, outhash, taskhash) 52 UNIQUE(method, outhash, taskhash)
48 ) 53 )
49 ''') 54 ''' % " ".join("%s %s," % (name, typ) for name, typ in TABLE_DEFINITION))
50 cursor.execute('PRAGMA journal_mode = WAL') 55 cursor.execute('PRAGMA journal_mode = WAL')
51 cursor.execute('PRAGMA synchronous = %s' % ('NORMAL' if sync else 'OFF')) 56 cursor.execute('PRAGMA synchronous = %s' % ('NORMAL' if sync else 'OFF'))
52 57
@@ -89,10 +94,10 @@ def chunkify(msg, max_chunk):
89 yield "\n" 94 yield "\n"
90 95
91 96
92def create_server(addr, dbname, *, sync=True): 97def create_server(addr, dbname, *, sync=True, upstream=None):
93 from . import server 98 from . import server
94 db = setup_database(dbname, sync=sync) 99 db = setup_database(dbname, sync=sync)
95 s = server.Server(db) 100 s = server.Server(db, upstream=upstream)
96 101
97 (typ, a) = parse_address(addr) 102 (typ, a) = parse_address(addr)
98 if typ == ADDR_TYPE_UNIX: 103 if typ == ADDR_TYPE_UNIX: