Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Mar 03 08:21
    medenes commented #280
  • Mar 01 19:24
    wvffle commented #395
  • Mar 01 13:07

    lganzzzo on master

    Add hints and advice to the thr… Merge pull request #396 from ba… (compare)

  • Mar 01 13:07
    lganzzzo closed #396
  • Mar 01 07:53
    bamkrs edited #396
  • Mar 01 07:53
    bamkrs review_requested #396
  • Mar 01 07:53
    bamkrs opened #396
  • Mar 01 07:43
    bamkrs commented #280
  • Mar 01 07:43
    bamkrs closed #280
  • Mar 01 07:43
    bamkrs commented #280
  • Mar 01 06:42
    bamkrs commented #395
  • Mar 01 06:42
    bamkrs commented #395
  • Mar 01 06:36
    bamkrs closed #324
  • Mar 01 06:36

    bamkrs on master

    Fix #324 (#395) * Attempt to p… (compare)

  • Mar 01 06:36
    bamkrs closed #395
  • Mar 01 00:01
    ktnr closed #394
  • Mar 01 00:01
    ktnr commented #394
  • Feb 28 23:43
    lganzzzo review_requested #395
  • Feb 28 23:29
    lganzzzo commented #394
  • Feb 28 23:22
    wvffle synchronize #395
oat++
@oatpp_io_twitter
oatpp::Object<UserDto> Database::createUser(const oatpp::Object<UserDto> &userDto) {
  auto conn = m_pool->acquire();
  auto collection = (*conn)[m_databaseName][m_collectionName]; //<-- collection name it can be anything!
  collection.insert_one(createMongoDocument(userFromDto(userDto)));
  return userDto;
}
You may reimplement it in the way most convenient to you. You are not bound to components
Quan Nguyen
@nguyenquan263
gotcha, thanks man
Quan Nguyen
@nguyenquan263
hey man...about installing mongocxx from your Dockerfile...can you show me a more detail way to install that
I used docker build for it...but nothing change :/
sorry..I'm so dummy
junyama
@junyama
I wrote the following code by modifying example-api-client. I wanted to define client as a member variable, so that I could call runExample when it is needed. I have modified the code several ways, but I had compile error. Please tell me how to do that. Thank you for your help in advance:
class SimpleExample {
private:
  constexpr static const char* TAG = "SimpleExample";
  //std::shared_ptr<DemoApiClient>& client;  //////this line does not work /////////////  
public:
   oatpp::String bodyStr;

   void createClient() {
        auto connectionProvider = tcp::client::ConnectionProvider::createShared({SERVER_ADDRESS, SERVER_PORT_NUMBER});
        auto requestExecutor = client::HttpRequestExecutor::createShared(connectionProvider);
        auto objectMapper = json::mapping::ObjectMapper::createShared();
        auto client = DemoApiClient::createShared(requestExecutor, objectMapper);

        runExample(client);
  }

  void runExample(const std::shared_ptr<DemoApiClient>& client) {
    {
        bodyStr = client->detectObject(0, "Jpeg data passed to POST")->readBodyToString();
        OATPP_LOGD(TAG, "[detectObject] bodyStr = '%s'", bodyStr->c_str());
oat++
@oatpp_io_twitter
Hey @junyama ,
you are trying to store client as a reference

Hey @nguyenquan263 ,

hey man...about installing mongocxx from your Dockerfile...can you show me a more detail way to install that
I used docker build for it...but nothing change :/

From example-mongodb/readme.md:

Installing mongocxx on Linux is an unclear and painful process. See ubuntu-cmake-mongocxx/Dockerfile for instructions that worked for us.

And the link to dockerfile - https://github.com/oatpp/dockerfiles/blob/master/ci/ubuntu-cmake-mongocxx/Dockerfile

oat++
@oatpp_io_twitter
What "more detail way" do you mean :)? There is a script

I used docker build for it...but nothing change :/

What exactly hasn't changed :)? How should I know that?

Hey @junyama , @nguyenquan263

Please note Oat++ chat is for Oat++ specific questions. Please direct c++ general questions and docker questions to the corresponding communities.

junyama
@junyama
@oatpp_io_twitter , this is my simple mistake. It was solved. I'm sorry for posting inappropriate question to the chat.
oat++
@oatpp_io_twitter
no worries
Quan Nguyen
@nguyenquan263
what's should be an ideal way for deploying oatpp app? is there any advice :D
oat++
@oatpp_io_twitter
Hey @nguyenquan263 , you can deploy oatpp service both on a VM or in docker
Both ways work good
jjmcwill
@jjmcwill
We currently have a REST HTTP server embedded in our product using cpprestsdk, which we need to replace. Because cpprestsdk used a multi-threaded implementation, we're looking at the multi-threaded facilities in oat++ to do something similar. Does oat++ use a pool of worker threads to process connections and tasks the same way cpprestsdk does? Is there any control over the number of threads created in oat++?
oat++
@oatpp_io_twitter

Hello @jjmcwill ,

In Oat++, it's a ConnectionHandler that is responsible for connection handling and for how-much threads it will be allocated.

The default HttpConnectionHandler available out-of-the-box will spawn a new thread for each new incoming connection.
If you want to modify this behavior - you can implement your own connection handler or extend the default one and modify its behavior.

jjmcwill
@jjmcwill
Thanks
sholmp
@sholmp
Is it intended behaviour that nested dtos are not created if you do createShared()on the upper level dto? From my experience the sub dtos must be initialized with separate createShared() calls, otherwise it crashes if you do e.g. dto->foo->bar = "baz"
oat++
@oatpp_io_twitter
Yes, that is a correct behavior
If you want them initialized you can give a default values to your fields
sholmp
@sholmp
@oatpp_io_twitter ok thx for reply
jjmcwill
@jjmcwill

Is the request object available inside a non-Async ENDPOINT declaration?

In other words, I have a standard ENDPOINT() { ...} and I want to look at the headers of the request. Not sure how to access the request object.

jjmcwill
@jjmcwill
I tried:
ENDPOINT("GET", "/", root, REQUEST(const std::shared_ptr<IncomingRequest>&, request)) {...}
But this doesn't compile .
oat++
@oatpp_io_twitter
Hey @jjmcwill , that is correct
What are the compiler errors ?
Try just remove const and & modifiers
oat++
@oatpp_io_twitter
Please let me know it worked for you @jjmcwill
jjmcwill
@jjmcwill
Yes that worked. Thanks!
oat++
@oatpp_io_twitter
👍
Quan Nguyen
@nguyenquan263
Hey man,
oatpp::Object<User> Database::userFromDto(const oatpp::Object<UserDto>& dto) {
auto user = User::createShared();
user->_id = dto->username;
user->username = dto->username;
user->active = dto->active;
user->role = dto->role;
return user;
}
How can I set user->id to the default ObjectID ? thanks
axelspoerl
@axelspoerl
Hi community,
I have troubles trying the multipart download example at https://oatpp.io/docs/features/upload-file with oat++ 1.2.5
The the compileer compaines that the members 'count' and 'getNamedPart' are not available in 'oatpp::web::mime::multipart::Multipart'
This is true, they are located in PartList.?pp which is included...
Thanks in advance for a hint on what I am missing.
Brgds
Axel
oat++
@oatpp_io_twitter

Hey @axelspoerl ,

Please see example here, in the oatpp tests

Yes, the "upload-file" docs are a bit outdated:(

Hey @nguyenquan263 ,

I don't understand the question.
You are setting the userId from dto->userName.
What do you mean by default user id???

oat++
@oatpp_io_twitter
Hey @axelspoerl , please let me know if you have more questions about multipart uploads
Quan Nguyen
@nguyenquan263
Sorry, I mean how can we set userId by it's object id instead of dto username...like an autoincrement id of sql :/
oat++
@oatpp_io_twitter

Hey @nguyenquan263 ,

Are you talking about Mongo?
If I remember correctly - ids won't be generated by database. Instead, a client should generate an objected on insertion.
So basically, when you insert an object - generate an objectId firsnt, then insert

You can use oatpp::mongo::bson::ObjectId to store the ObjectId datatype
Also to generate a new objId it should be something like that:
oatpp::mongo::bson::ObjectId objId = oatpp::mongo::bson::type::ObjectId();
Yeah, not really obvious - but that's for now
jjmcwill
@jjmcwill

:Using oatpp::network::server::run(bool) is deprecated and will be removed in the next release. Please implement your own threading.

Is deprecating server::run(true) in the works? If I called server::run() in a separate thread that blocks, how would I cleanly signal that thread to shutdown and clean up?

oat++
@oatpp_io_twitter
Hey @jjmcwill ,
Please checkout this exaple - how to start/stop server
jjmcwill
@jjmcwill
Okay thanks!
oat++
@oatpp_io_twitter
See the readme there for more info