0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
mongodb/s/request.h

75 lines
1.4 KiB
C
Raw Normal View History

// request.h
#pragma once
2009-02-06 20:25:06 +01:00
#include "../stdafx.h"
#include "../util/message.h"
#include "../db/dbmessage.h"
2009-02-13 03:03:46 +01:00
#include "config.h"
namespace mongo {
2009-02-20 16:46:42 +01:00
class Request : boost::noncopyable {
public:
2009-02-06 21:44:21 +01:00
Request( Message& m, MessagingPort& p );
// ---- message info -----
const char * getns(){
return _d.getns();
}
2009-02-19 18:55:01 +01:00
int op(){
return _m.data->operation();
}
bool expectResponse(){
return op() == dbQuery || op() == dbGetMore;
}
MSGID id(){
return _id;
}
2009-02-06 21:44:21 +01:00
DBConfig * getConfig(){
return _config;
}
2009-02-20 16:46:42 +01:00
ShardInfo * getShardInfo(){
return _shardInfo;
}
// ---- remote location info -----
2009-02-06 21:44:21 +01:00
string singleServerName();
2009-02-06 21:44:21 +01:00
const char * primaryName(){
return _config->getPrimary().c_str();
2009-02-06 21:44:21 +01:00
}
// ---- low level access ----
2009-02-17 17:41:34 +01:00
void reply( Message & response ){
_p.reply( _m , response , _id );
}
Message& m(){ return _m; }
DbMessage& d(){ return _d; }
MessagingPort& p(){ return _p; }
2009-02-19 18:55:01 +01:00
void process();
private:
Message& _m;
DbMessage _d;
MessagingPort& _p;
MSGID _id;
2009-02-06 21:44:21 +01:00
DBConfig * _config;
ShardInfo * _shardInfo;
};
}
2009-02-23 19:56:54 +01:00
#include "strategy.h"