Three Wrappers One Interface
All three of these expose the same read(key) -> bytes method that the rest of the codebase calls. The team calls all three "our decorators".
class W1:
def __init__(self, legacy):
self.legacy = legacy
def read(self, key: str) -> bytes:
rec = self.legacy.GetBlobRecord(key.encode("ascii"))
return rec.payload_bytes()
class W2:
def __init__(self, dsn: str):
self.dsn = dsn
self.inner = None
def read(self, key: str) -> bytes:
if self.inner is None:
self.inner = BlobStore(self.dsn) # opens 40 sockets, ~300 ms
return self.inner.read(key)
class W3:
def __init__(self, inner):
self.inner = inner
def read(self, key: str) -> bytes:
return gzip.decompress(self.inner.read(key))
Which labelling is right?
Sign in to answer questions and track your progress
Sign In