Raised This Month: $7 Target: $400
 1% 

Module: GoldSrc REST In Pawn (gRIP)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Inline
New Member
Join Date: May 2016
Old 04-13-2019 , 15:26   Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #1

GoldSrc Rest In Pawn (gRIP)

GRIP started as an effort to make an asynchronous REST API for Pawn.

Months ago I was invited to participate in the GameX project initiative. GameX was striving to create a modern administrating system for HLDS. To do this many problems queued up, waiting to be solved. One of the major challenges was the interaction with the database.

A long time ago before GRIP and GameX, web-server and HLDS modified database direcly. It was a crude and a brutal approach, which is one of the sources of todays problems.
GRIP was created to fill this gap, by providing asynchronous REST Client for Pawn. Database access and modification, with the server-specific code are delegated to the server and encapsulated in REST API, which is a sophisticated and modern approach.

Before we proceed, I should mention that HLDS and Pawn operate on the main thread. Generally code isn't concurrent.

So to sum up there are 3 key requirements for the GRIP.
1) Low-latency
2) Asynchronous API
3) Support for the modern web standards.
4) Builtin JSON support (to bypass limits on the AMXX buffer sizes)

Solutions implemented before, usually achieved only second requirement or just basically nothing. They used raw sockets and blocked the main thread for the IO.
To solve blocking problem requests were dispatched to another thread (See for SQL_ThreadQuery for example). This approach has several problems. One of them is the difficulty on concurrent and safe programming in C++. To speed up things, thread pool should be written. With bad dependency management... This is just a mess!

Why don't use modern programming language which is as fast as C++, but is safe, has greater libraries and tooling support? Yeah, basically no reasons to not to.

Rust has many libraries dedicated to high-performance HTTP(s) requests, implemented (at the lowest level) using non-blocking sockets. It is extremely easy to write something in Rust, which is otherwise nearly impossible in C++.

Thus, I, with the team of dedicated supporters give a birth to a GRIP. It supports modern web standards, will eventually support JSON and many other things..

API

To familiarize yourself with the API you need little to no knowledge about it's inner structure. You should be familiar with Pawn scripting language in the context of the AMX Mod X and REST API.

First of all, let's see whats the most important point. All the necessary optimizations are done under the hood, developer is exposed only to the high-level view of the things.

You start a request with the corresponding arguments and just after that, function returns immediately. There is no blocking and no way to achieve it by design.

Next I think it is important to describe idiomatic callback implementation. User is forced to provide completion handler, which is guaranteed to be called in the case of success, timeout, cancellation, etc.. Requests completion order is unspecified. On completion, response status should be checked. No function silently fails. it is strict API which forces users to consider all cases. All network requests are done simultaneously in the implementation specified order.

JSON API tries to mimic corresponding json.inc file from AMX Mod X. Some things were removed/changed, because in my opinion they are bad design choices. Such dangerous components should rarely cause compilation errors in the plugin, but in the majority of the cases gRIP JSON API is drop-in replacement of AMX Mod X json.inc .

Anyway they are some fundamental places where my point of view and that of AMX Mod X JSON implementation diverge drastically. Here is semi-complete list of such [problems](https://github.com/alliedmodders/amx...thor%3AIn-line).

Building

Currently building only on the Linux is supported, but there are some discussions and ongoing work for Windows support. Anyway, the best way to get list of up to date build time dependencies is to view [.travis.yml](https://github.com/In-line/grip/blob/master/.travis.yml) section containing debian packages.

After installing these dependencies you need to install Rust, follow your distribution specific instruction or simply download it from [rustup](https://rustup.rs/).

Because, currently Rustup ships by default only host target, you need to manually install 32-bit x86 target for Rust.
Code:
$ rustup target install i686-unknown-linux-gnu
To get nice IDE for Rust and C++, I recommend first of all googling and choosing something based on your taste, but I usually develop using CLion with InteliJ Rust plugin, it is very convenient to use in with mixed Rust/C++ project.

To start building you should use cmake, so first of all, do standard procedure.
Code:
$ cmake . # Generate makefile
$ make # Make makefile.
This will compile Rust code, C++ code and produce single shared library at the end. There is no much to tell about this process, but feel free to ask questions (even stupid!). I appreciate contributions and will help anybody, who wants to be involved.

Download links
Inline is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-16-2019 , 07:58   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #2

Well done. I was also looking into using Rust for modules, this is awesome.
__________________
klippy is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 04-20-2019 , 04:12   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #3

I have kept an eye on gRIP for sometime as I needed HTTPS access, and couldn't do it otherwise. They should get rid of the curent JSON module and integrate gRIP with it's builtin JSON library into amxmodx 1.9.0 if you wouldn't mind, as an official module ensures long term support. It brings greatly needed features that can't be done without it.

Last edited by PartialCloning; 04-20-2019 at 04:13.
PartialCloning is offline
Inline
New Member
Join Date: May 2016
Old 04-26-2019 , 05:40   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #4

Quote:
Originally Posted by PartialCloning View Post
I have kept an eye on gRIP for sometime as I needed HTTPS access, and couldn't do it otherwise. They should get rid of the curent JSON module and integrate gRIP with it's builtin JSON library into amxmodx 1.9.0 if you wouldn't mind, as an official module ensures long term support. It brings greatly needed features that can't be done without it.
It will happen eventually, if JSON module provides API for doing that and will improve itself.
Inline is offline
Old 10-30-2019, 23:17
gabuch2
This message has been deleted by gabuch2. Reason: Nevermind, I realized I downloaded the wrong file
hckr
Junior Member
Join Date: Sep 2019
Old 12-14-2019 , 21:04   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #5

I must wait for gRIP to be available for windows =)
hckr is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 12-28-2019 , 12:49   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #6

Quote:
Originally Posted by Inline View Post
Solutions implemented before, usually achieved only second requirement or just basically nothing. They used raw sockets and blocked the main thread for the IO.
To solve blocking problem requests were dispatched to another thread (See for SQL_ThreadQuery for example). This approach has several problems. One of them is the difficulty on concurrent and safe programming in C++. To speed up things, thread pool should be written. With bad dependency management... This is just a mess!

....

Rust has many libraries dedicated to high-performance HTTP(s) requests, implemented (at the lowest level) using non-blocking sockets. It is extremely easy to write something in Rust, which is otherwise nearly impossible in C++.
I am confused
There are two types of sockets, IIRC, Blocking and non-blocking.

If this module is using non-blocking sockets, how it different from many already existing non-blocking modules (for sockets) on this community ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Old 12-09-2020, 12:02
gabuch2
This message has been deleted by gabuch2. Reason: The problem was on my DNS file, it was completely unrelated.
menkisa
Junior Member
Join Date: Sep 2011
Old 01-03-2021 , 13:40   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #7

...

Last edited by menkisa; 12-24-2021 at 21:06.
menkisa is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 08-18-2021 , 16:02   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #8

I do not understand the installation process
please guide me
__________________
amirwolf is offline
wilian159
Member
Join Date: Dec 2013
Old 02-10-2022 , 16:42   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #9

what is the chance of this module becoming 'official' for amxmodx? would be very interesting. the community always reports problems etc.
wilian159 is offline
brolpzt
New Member
Join Date: Mar 2023
Old 03-10-2023 , 13:05   Re: Module: GoldSrc REST In Pawn (gRIP)
Reply With Quote #10

guys,

if anyone can help me

do any of you use gRIP on your servers?
is it worth using it instead of mysql?
does it work better in terms of performance than mysql will?
in the case of a 32 player server
brolpzt is offline
Old 07-30-2023, 01:04
Zergcito
This message has been deleted by Zergcito. Reason: 0.0.0.0-test isnt working...
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode