new(userspace/falco): store context metadata for future usage

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
Leonardo Di Donato 2019-09-16 05:22:40 +00:00 committed by Leo Di Donato
parent 21e588394f
commit c389ec1b61
2 changed files with 11 additions and 1 deletions

View File

@ -29,16 +29,23 @@ context::context(grpc::ServerContext* ctx):
get_metadata(meta_session, session_id);
get_metadata(meta_session, request_id);
bool has_meta = false;
std::stringstream meta;
if(!session_id.empty())
{
meta << "[sid=" << session_id << "]";
has_meta = true;
}
if(!request_id.empty())
{
meta << "[rid=" << request_id << "]";
has_meta = true;
}
if(has_meta)
{
meta << " ";
}
m_prefix = meta.str();
}
void context::get_metadata(std::string key, std::string& val)

View File

@ -18,6 +18,8 @@ limitations under the License.
#pragma once
#include <string>
#ifdef GRPC_INCLUDE_IS_GRPCPP
#include <grpcpp/grpcpp.h>
#else
@ -37,6 +39,7 @@ public:
private:
grpc::ServerContext* m_ctx = nullptr;
std::string m_prefix;
};
class stream_context : public context