mirror of
https://github.com/deepseek-ai/3FS
synced 2025-06-26 18:16:45 +00:00
Initial commit
This commit is contained in:
39
src/fbs/macros/IStub.h
Normal file
39
src/fbs/macros/IStub.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "common/utils/Coroutine.h"
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE
|
||||
#undef DEFINE_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE(name, fbsns) \
|
||||
class I##name##ServiceStub { \
|
||||
public: \
|
||||
using InterfaceType = I##name##ServiceStub; \
|
||||
\
|
||||
virtual ~I##name##ServiceStub() = default;
|
||||
|
||||
#ifdef FINISH_FBS_SERVICE
|
||||
#undef FINISH_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define FINISH_FBS_SERVICE(name, fbsns) }
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD
|
||||
#undef DEFINE_FBS_SERVICE_METHOD
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
|
||||
virtual CoTryTask<flatns::rsptype> name(const flatns::reqtype &req) = 0
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
|
||||
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
|
||||
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
|
||||
39
src/fbs/macros/ISyncStub.h
Normal file
39
src/fbs/macros/ISyncStub.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "common/utils/Result.h"
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE
|
||||
#undef DEFINE_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE(name, fbsns) \
|
||||
class I##name##ServiceStub { \
|
||||
public: \
|
||||
using InterfaceType = I##name##ServiceStub; \
|
||||
\
|
||||
virtual ~I##name##ServiceStub() = default;
|
||||
|
||||
#ifdef FINISH_FBS_SERVICE
|
||||
#undef FINISH_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define FINISH_FBS_SERVICE(name, fbsns) }
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD
|
||||
#undef DEFINE_FBS_SERVICE_METHOD
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
|
||||
virtual hf3fs::Result<flatns::rsptype> name(const flatns::reqtype &req) = 0
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
|
||||
virtual hf3fs::Result<Void> name(const flatns::reqtype &req) = 0
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
|
||||
virtual hf3fs::Result<rtype> name(const flatns::reqtype &req) = 0
|
||||
8
src/fbs/macros/SerdeDef.h
Normal file
8
src/fbs/macros/SerdeDef.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef DEFINE_SERDE_SERVICE_METHOD_FULL
|
||||
#define DEFINE_SERDE_SERVICE_METHOD_FULL(ServiceName, methodName, MethodName, MethodId, RequestType, ResponseType)
|
||||
#endif
|
||||
|
||||
#ifndef DEFINE_SERDE_SERVICE_METHOD
|
||||
#define DEFINE_SERDE_SERVICE_METHOD(ServiceName, methodName, MethodName, MethodId) \
|
||||
DEFINE_SERDE_SERVICE_METHOD_FULL(ServiceName, methodName, MethodName, MethodId, MethodName##Req, MethodName##Rsp)
|
||||
#endif
|
||||
46
src/fbs/macros/Stub.h
Normal file
46
src/fbs/macros/Stub.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "common/utils/Coroutine.h"
|
||||
#include "common/utils/Result.h"
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE
|
||||
#undef DEFINE_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE(name, fbsns) \
|
||||
template <typename Ctx> \
|
||||
class name##ServiceStub : public I##name##ServiceStub { \
|
||||
public: \
|
||||
using ContextType = Ctx; \
|
||||
using name##Client = ::fbsns::name##Client<Ctx>; \
|
||||
\
|
||||
explicit name##ServiceStub(Ctx ctx) \
|
||||
: client_(std::move(ctx)) {}
|
||||
|
||||
#ifdef FINISH_FBS_SERVICE
|
||||
#undef FINISH_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define FINISH_FBS_SERVICE(name, fbsns) \
|
||||
private: \
|
||||
name##Client client_; \
|
||||
}
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD
|
||||
#undef DEFINE_FBS_SERVICE_METHOD
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
|
||||
CoTryTask<flatns::rsptype> name(const flatns::reqtype &req) override
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
|
||||
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
|
||||
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
|
||||
45
src/fbs/macros/SyncStub.h
Normal file
45
src/fbs/macros/SyncStub.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "common/utils/Result.h"
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE
|
||||
#undef DEFINE_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE(name, fbsns) \
|
||||
template <typename Ctx> \
|
||||
class name##ServiceStub : public I##name##ServiceStub { \
|
||||
public: \
|
||||
using ContextType = Ctx; \
|
||||
using name##Client = ::fbsns::name##Client<Ctx>; \
|
||||
\
|
||||
explicit name##ServiceStub(Ctx ctx) \
|
||||
: client_(std::move(ctx)) {}
|
||||
|
||||
#ifdef FINISH_FBS_SERVICE
|
||||
#undef FINISH_FBS_SERVICE
|
||||
#endif
|
||||
|
||||
#define FINISH_FBS_SERVICE(name, fbsns) \
|
||||
private: \
|
||||
name##Client client_; \
|
||||
}
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD
|
||||
#undef DEFINE_FBS_SERVICE_METHOD
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
|
||||
hf3fs::Result<flatns::rsptype> name(const flatns::reqtype &req) override
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_VOID
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
|
||||
hf3fs::Result<Void> name(const flatns::reqtype &req) override
|
||||
|
||||
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
|
||||
#endif
|
||||
|
||||
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
|
||||
hf3fs::Result<rtype> name(const flatns::reqtype &req) override
|
||||
7
src/fbs/macros/Undef.h
Normal file
7
src/fbs/macros/Undef.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifdef DEFINE_SERDE_SERVICE_METHOD
|
||||
#undef DEFINE_SERDE_SERVICE_METHOD
|
||||
#endif
|
||||
|
||||
#ifdef DEFINE_SERDE_SERVICE_METHOD_FULL
|
||||
#undef DEFINE_SERDE_SERVICE_METHOD_FULL
|
||||
#endif
|
||||
Reference in New Issue
Block a user