Apache Mesos
fetcher.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __MESOS_URI_FETCHER_HPP__
18 #define __MESOS_URI_FETCHER_HPP__
19 
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 #include <mesos/mesos.hpp>
25 
26 #include <process/future.hpp>
27 #include <process/owned.hpp>
28 #include <process/shared.hpp>
29 
30 #include <stout/hashmap.hpp>
31 #include <stout/nothing.hpp>
32 
33 #include <mesos/uri/uri.hpp>
34 
35 namespace mesos {
36 namespace uri {
37 
38 
46 class Fetcher
47 {
48 public:
52  class Plugin
53  {
54  public:
55  virtual ~Plugin() {}
56 
60  virtual std::set<std::string> schemes() const = 0;
61 
65  virtual std::string name() const = 0;
66 
76  // TODO(gilbert): Change the parameter 'data' as a hashmap
77  // of <string, Secret::Value>, and update the comment.
79  const URI& uri,
80  const std::string& directory,
81  const Option<std::string>& data = None()) const = 0;
82  };
83 
89  Fetcher(const std::vector<process::Owned<Plugin>>& plugins);
90 
99  // TODO(jieyu): Consider using 'Path' for 'directory' here.
101  const URI& uri,
102  const std::string& directory,
103  const Option<std::string>& data = None()) const;
104 
115  const URI& uri,
116  const std::string& directory,
117  const std::string& name,
118  const Option<std::string>& data = None()) const;
119 
120 private:
121  Fetcher(const Fetcher&) = delete; // Not copyable.
122  Fetcher& operator=(const Fetcher&) = delete; // Not assignable.
123 
126 };
127 
128 } // namespace uri {
129 } // namespace mesos {
130 
131 #endif // __MESOS_URI_FETCHER_HPP__
process::Future< Nothing > fetch(const URI &uri, const std::string &directory, const Option< std::string > &data=None()) const
Fetches a URI to the given directory.
Fetcher(const std::vector< process::Owned< Plugin >> &plugins)
Create the Fetcher instance with the given plugins.
Definition: hashmap.hpp:38
virtual process::Future< Nothing > fetch(const URI &uri, const std::string &directory, const Option< std::string > &data=None()) const =0
Fetches a URI to the given directory.
virtual ~Plugin()
Definition: fetcher.hpp:55
Definition: none.hpp:27
virtual std::set< std::string > schemes() const =0
Returns the URI schemes that this plugin handles.
Provides an abstraction for fetching URIs.
Definition: fetcher.hpp:46
Definition: owned.hpp:35
virtual std::string name() const =0
Returns the name that this plugin registered with.
constexpr const char * name
Definition: shell.hpp:41
Represents a fetcher plugin that handles one or more URI schemes.
Definition: fetcher.hpp:52