Browse Source

[2209] Interface of the getCachedZoneWriter()

Unlike what the ticket suggests, it takes concrete origin parameter, not
some yet unknown config value, for two reasons:
 * The format of config is not known.
 * Leaking some details about what memory segment or whatever is being
   used for the cache through the interface looks like a bad idea. Even
   leaking the existence of the cache is enough.
Michal 'vorner' Vaner 12 years ago
parent
commit
61d475331f
1 changed files with 26 additions and 0 deletions
  1. 26 0
      src/lib/datasrc/client_list.h

+ 26 - 0
src/lib/datasrc/client_list.h

@@ -43,6 +43,7 @@ typedef boost::shared_ptr<DataSourceClientContainer>
 // and hide real definitions except for itself and tests.
 // and hide real definitions except for itself and tests.
 namespace memory {
 namespace memory {
 class InMemoryClient;
 class InMemoryClient;
+class ZoneWriter;
 }
 }
 
 
 /// \brief The list of data source clients.
 /// \brief The list of data source clients.
@@ -289,6 +290,31 @@ public:
     ///      the original data source no longer contains the cached zone.
     ///      the original data source no longer contains the cached zone.
     ReloadResult reload(const dns::Name& zone);
     ReloadResult reload(const dns::Name& zone);
 
 
+    /// \brief Return value of getCachedZoneWriter()
+    ///
+    /// A pair containing status and the zone writer, for the
+    /// getCachedZoneWriter() method.
+    typedef std::pair<ReloadResult, boost::shared_ptr<memory::ZoneWriter> >
+        ZoneWriterPair;
+
+    /// \brief Return a zone writer that can be used to reload a zone.
+    ///
+    /// This looks up a cached copy of zone and returns the ZoneWriter
+    /// that can be used to reload the content of the zone. This can
+    /// be used instead of reload() -- reload() works synchronously, which
+    /// is not what is needed every time.
+    ///
+    /// \param zone The origin of the zone to reload.
+    /// \return The result has two parts. The first one is a status describing
+    ///     if it worked or not (and in case it didn't, also why). If the status
+    ///     is ZONE_RELOADED, the second part contains a shared pointer to the
+    ///     writer. If the status is anything else, the second part is NULL.
+    /// \throw DataSourceError or anything else that the data source
+    ///      containing the zone might throw is propagated.
+    /// \throw DataSourceError if something unexpected happens, like when
+    ///      the original data source no longer contains the cached zone.
+    ZoneWriterPair getCachedZoneWriter(const dns::Name& zone);
+
     /// \brief Implementation of the ClientList::find.
     /// \brief Implementation of the ClientList::find.
     virtual FindResult find(const dns::Name& zone,
     virtual FindResult find(const dns::Name& zone,
                             bool want_exact_match = false,
                             bool want_exact_match = false,