Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using as library #2387

Open
flashpixx opened this issue Apr 17, 2024 · 3 comments
Open

Using as library #2387

flashpixx opened this issue Apr 17, 2024 · 3 comments

Comments

@flashpixx
Copy link

Hello,

I'm interested in this project and I'm a Rust newby. I'm working on a project with network e.g. nmap results and I would like to build a microservice with Tokio / Axum to execute Prolog terms.
Is it possible to use this project as a library dependency in my project. For my use case I need to read / parse a pl-file with static rules and append facts (terms) which I can build based on my NMAP results and I need to share this instance over multiple threads in Axum, so I get run some post and get HTTP queries (by converting JSON input into prolog terms).

I didn't find this in the documentation. Thanks a lot of helping

@aarroyoc
Copy link
Contributor

There are several ways to do what you want to do. If the only thing you want to do in your microservice is executing Prolog terms, take a look at library(http/http_server), which is a HTTP(S) server which can be used from Prolog. It still has some rough edges, but it may work for you already. I have more samples of this library usage if you want to take this route.

The other way is using Scryer Prolog as a library. This is not documented yet but the methods available to you are under src/machine/lib_machine.rs. Some people are already using them, like https://github.com/coasys

@flashpixx
Copy link
Author

I will choose the 2nd option, because I would like to get a single executable later

@flashpixx
Copy link
Author

Is there any documentation how to build terms and queries and execute then within code?
For my use-case I would like to do:

  1. read a static pl-file with some rules
  2. add multiple facts (terms) based on NMAP results, so I can build strings and pass it into the machine
  3. execute some queries within Tokio HTTP handlers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants