aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-11 19:15:32 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-11 19:15:32 +0300
commit623b75523fbec13f26b532972a46e75faf149088 (patch)
treece04a52fd058b3017037ecc4a843a39c2a829575 /library
parent4f5398551111a2b05b55de391d5d296bd0a670bf (diff)
downloadydb-623b75523fbec13f26b532972a46e75faf149088.tar.gz
intermediate changes
ref:ee911405f4248489c0aa2817134b7162e0b94f18
Diffstat (limited to 'library')
-rw-r--r--library/cpp/deprecated/mapped_file/mapped_file.cpp64
-rw-r--r--library/cpp/deprecated/mapped_file/mapped_file.h72
-rw-r--r--library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp18
-rw-r--r--library/cpp/deprecated/mapped_file/ya.make9
-rw-r--r--library/cpp/messagebus/test/ut/www_ut.cpp19
-rw-r--r--library/cpp/messagebus/test/ut/ya.make2
-rw-r--r--library/cpp/messagebus/www/www.cpp16
-rw-r--r--library/cpp/messagebus/www/ya.make9
8 files changed, 27 insertions, 182 deletions
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp
deleted file mode 100644
index b0e4511299..0000000000
--- a/library/cpp/deprecated/mapped_file/mapped_file.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "mapped_file.h"
-
-#include <util/generic/yexception.h>
-#include <util/system/defaults.h>
-#include <util/system/hi_lo.h>
-#include <util/system/filemap.h>
-
-TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) {
- Map_ = map;
- i64 len = Map_->Length();
- if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32))
- ythrow yexception() << "File '" << dbgName << "' mapping error: " << len << " too large";
-
- Map_->Map(0, static_cast<size_t>(len));
-}
-
-TMappedFile::TMappedFile(const TFile& file, TFileMap::EOpenMode om, const char* dbgName)
- : Map_(nullptr)
-{
- init(file, om, dbgName);
-}
-
-void TMappedFile::precharge(size_t off, size_t size) const {
- if (!Map_)
- return;
-
- Map_->Precharge(off, size);
-}
-
-void TMappedFile::init(const TString& name) {
- THolder<TFileMap> map(new TFileMap(name));
- TMappedFile newFile(map.Get(), name.data());
- Y_UNUSED(map.Release());
- newFile.swap(*this);
- newFile.term();
-}
-
-void TMappedFile::init(const TString& name, size_t length, TFileMap::EOpenMode om) {
- THolder<TFileMap> map(new TFileMap(name, length, om));
- TMappedFile newFile(map.Get(), name.data());
- Y_UNUSED(map.Release());
- newFile.swap(*this);
- newFile.term();
-}
-
-void TMappedFile::init(const TFile& file, TFileMap::EOpenMode om, const char* dbgName) {
- THolder<TFileMap> map(new TFileMap(file, om));
- TMappedFile newFile(map.Get(), dbgName);
- Y_UNUSED(map.Release());
- newFile.swap(*this);
- newFile.term();
-}
-
-void TMappedFile::init(const TString& name, TFileMap::EOpenMode om) {
- THolder<TFileMap> map(new TFileMap(name, om));
- TMappedFile newFile(map.Get(), name.data());
- Y_UNUSED(map.Release());
- newFile.swap(*this);
- newFile.term();
-}
-
-void TMappedFile::flush() {
- Map_->Flush();
-}
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h
deleted file mode 100644
index 45859ed65a..0000000000
--- a/library/cpp/deprecated/mapped_file/mapped_file.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#pragma once
-
-#include <util/generic/flags.h>
-#include <util/generic/ptr.h>
-#include <util/generic/string.h>
-#include <util/generic/utility.h>
-#include <util/generic/yexception.h>
-#include <util/system/align.h>
-#include <util/system/file.h>
-#include <util/system/filemap.h>
-#include <util/system/yassert.h>
-
-#include <cstdio>
-#include <new>
-
-/// Deprecated (by pg@), use TFileMap or TMemoryMap instead
-class TMappedFile {
-private:
- TFileMap* Map_;
-
-private:
- TMappedFile(TFileMap* map, const char* dbgName);
-
-public:
- TMappedFile() {
- Map_ = nullptr;
- }
-
- ~TMappedFile() {
- term();
- }
-
- explicit TMappedFile(const TString& name) {
- Map_ = nullptr;
- init(name, TFileMap::oRdOnly);
- }
-
- TMappedFile(const TFile& file, TFileMap::EOpenMode om = TFileMap::oRdOnly, const char* dbgName = "unknown");
-
- void init(const TString& name);
-
- void init(const TString& name, TFileMap::EOpenMode om);
-
- void init(const TString& name, size_t length, TFileMap::EOpenMode om);
-
- void init(const TFile&, TFileMap::EOpenMode om = TFileMap::oRdOnly, const char* dbgName = "unknown");
-
- void flush();
-
- void term() {
- if (Map_) {
- Map_->Unmap();
- delete Map_;
- Map_ = nullptr;
- }
- }
-
- size_t getSize() const {
- return (Map_ ? Map_->MappedSize() : 0);
- }
-
- void* getData(size_t pos = 0) const {
- Y_ASSERT(!Map_ || (pos <= getSize()));
- return (Map_ ? (void*)((unsigned char*)Map_->Ptr() + pos) : nullptr);
- }
-
- void precharge(size_t pos = 0, size_t size = (size_t)-1) const;
-
- void swap(TMappedFile& file) noexcept {
- DoSwap(Map_, file.Map_);
- }
-};
diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp
deleted file mode 100644
index afbd5b3358..0000000000
--- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <library/cpp/deprecated/mapped_file/mapped_file.h>
-#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/system/fs.h>
-
-Y_UNIT_TEST_SUITE(TMappedFileTest) {
- static const char* FileName_("./mappped_file");
- Y_UNIT_TEST(TestFileMapEmpty) {
- TFile file(FileName_, CreateAlways | WrOnly);
- file.Close();
-
- TMappedFile map;
- map.init(FileName_);
- map.getData(0);
-
- NFs::Remove(FileName_);
- }
-};
diff --git a/library/cpp/deprecated/mapped_file/ya.make b/library/cpp/deprecated/mapped_file/ya.make
deleted file mode 100644
index 415c438382..0000000000
--- a/library/cpp/deprecated/mapped_file/ya.make
+++ /dev/null
@@ -1,9 +0,0 @@
-LIBRARY()
-
-OWNER(g:util)
-
-SRCS(
- mapped_file.cpp
-)
-
-END()
diff --git a/library/cpp/messagebus/test/ut/www_ut.cpp b/library/cpp/messagebus/test/ut/www_ut.cpp
new file mode 100644
index 0000000000..181984db47
--- /dev/null
+++ b/library/cpp/messagebus/test/ut/www_ut.cpp
@@ -0,0 +1,19 @@
+#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/resource/resource.h>
+
+Y_UNIT_TEST_SUITE(Www) {
+ Y_UNIT_TEST(messagebus_js) {
+ auto str = NResource::Find("/messagebus.js");
+ UNIT_ASSERT(str.Contains("logTransform"));
+ UNIT_ASSERT(str.Contains("plotHist"));
+ }
+
+ Y_UNIT_TEST(busico_png) {
+ auto str = NResource::Find("/bus-ico.png");
+ UNIT_ASSERT(str.Contains("PNG")); //header
+ }
+
+ Y_UNIT_TEST(not_exist) {
+ UNIT_ASSERT_EXCEPTION(NResource::Find("/not_exist"), yexception);
+ }
+}
diff --git a/library/cpp/messagebus/test/ut/ya.make b/library/cpp/messagebus/test/ut/ya.make
index fe1b4961d6..bf15564d95 100644
--- a/library/cpp/messagebus/test/ut/ya.make
+++ b/library/cpp/messagebus/test/ut/ya.make
@@ -18,6 +18,7 @@ PEERDIR(
library/cpp/messagebus
library/cpp/messagebus/test/helper
library/cpp/messagebus/www
+ library/cpp/resource
)
SRCS(
@@ -29,6 +30,7 @@ SRCS(
starter_ut.cpp
sync_client_ut.cpp
locator_uniq_ut.cpp
+ www_ut.cpp
../../actor/actor_ut.cpp
../../actor/ring_buffer_ut.cpp
../../actor/tasks_ut.cpp
diff --git a/library/cpp/messagebus/www/www.cpp b/library/cpp/messagebus/www/www.cpp
index 62ec241d85..6c8b4bc732 100644
--- a/library/cpp/messagebus/www/www.cpp
+++ b/library/cpp/messagebus/www/www.cpp
@@ -6,11 +6,11 @@
#include <library/cpp/messagebus/remote_connection_status.h>
#include <library/cpp/monlib/deprecated/json/writer.h>
-#include <library/cpp/archive/yarchive.h>
#include <library/cpp/http/fetch/httpfsm.h>
#include <library/cpp/http/fetch/httpheader.h>
#include <library/cpp/http/server/http.h>
#include <library/cpp/json/writer/json.h>
+#include <library/cpp/resource/resource.h>
#include <library/cpp/uri/http_url.h>
#include <util/string/cast.h>
@@ -165,18 +165,6 @@ namespace {
}
-const unsigned char WWW_STATIC_DATA[] = {
-#include "www_static.inc"
-};
-
-class TWwwStaticLoader: public TArchiveReader {
-public:
- TWwwStaticLoader()
- : TArchiveReader(TBlob::NoCopy(WWW_STATIC_DATA, sizeof(WWW_STATIC_DATA)))
- {
- }
-};
-
struct TBusWww::TImpl {
// TODO: use weak pointers
TNamedValues<TBusMessageQueuePtr> Queues;
@@ -728,7 +716,7 @@ struct TBusWww::TImpl {
} else {
os << HTTP_OK_BIN;
}
- TBlob blob = Singleton<TWwwStaticLoader>()->ObjectBlobByKey(TString("/") + TString(path));
+ auto blob = NResource::Find(TString("/") + TString(path));
os.Write(blob.Data(), blob.Size());
}
diff --git a/library/cpp/messagebus/www/ya.make b/library/cpp/messagebus/www/ya.make
index 972390cea3..b0488bf0ef 100644
--- a/library/cpp/messagebus/www/ya.make
+++ b/library/cpp/messagebus/www/ya.make
@@ -7,14 +7,13 @@ SRCS(
www.cpp
)
-ARCHIVE(
- NAME www_static.inc
- messagebus.js
- bus-ico.png
+RESOURCE(
+ messagebus.js /messagebus.js
+ bus-ico.png /bus-ico.png
)
PEERDIR(
- library/cpp/archive
+ library/cpp/resource
library/cpp/cgiparam
library/cpp/html/pcdata
library/cpp/http/fetch