GithubHelp home page GithubHelp logo

hashicraft / fabric-microservices-mod Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 148.45 MB

Mod containing blocks like database and http connectors for building microservices in Minecraft

License: Creative Commons Zero v1.0 Universal

Java 91.85% HCL 3.16% Dockerfile 0.81% Shell 2.38% JavaScript 1.80%

fabric-microservices-mod's Introduction

Microservices in MineCraft Fabric Mod

Documentation WIP.

Requirements:

Webserver Block

The webserver block is a block that can be placed in the world and will start a webserver on the specified port. For each request it receives it will output a data item with the request body and the request_id.

To send a response to the client, you can insert a data item with the correct request_id. When a data item with the a request_id is inserted into a database block the request_id will be automatically added to any response from the database.

Database Block

The database block is a block that can be placed in the world that allows interaction with a postgres database. A query is trigger by adding a data item to the block. If this data item comes from a Webserver block and contains a request_id. It will automatically add the request_id to any response from the database.

The query that the database executes will automatically be serialized to JSON and added to the response data item. This can then be used to send a response to the client using the Webserver block.

Interpolation

The database and webserver blocks both support interpolation for their configuration. This enables you to use environment variables, the content of files or json path.

Environment Variables

You can use environment variables in the configuration by using the following syntax:

${{env("name")}}

This would result in the value of the environment variable MICROSERVICES_name being used as a replacement for the interpolation.

Note: For security Only environment variables prefixed with MICROSERVICES_ will be available for interpolation.

File Content

You can use the content of a file in the configuration by using the following syntax:

${{file("path")}}

JSON Path

JSON Path is a way to extract data from a JSON object. You can use JSON Path in the configuration

${{json_path('{"name":"nic"}','$.name')}}

Note: interpolation functions can be used as parameters for interpolation functions the following would be valid.

${{json_path('${{file("myfile.json")}}','$.name')}}

Running the example server and database

You can run an example server which has access to a postgres database. The server will be running on minecraft.container.local.jmpd.in:25565 and the database will be running on postgres.container.local.jmpd.in:5432.

To connect to the database you can use the following credentials:

  • Username: postgres
  • Password: password
  • Database: minecraft
โžœ jumppad up ./jumppad
Running configuration from  ./jumppad  -- press ctrl c to cancel

INFO Creating resources from configuration path=/home/nicj/go/src/github.com/hashicraft/fabric-microservices-mod/jumppad
INFO Creating ImageCache ref=resource.image_cache.default
INFO Creating output ref=output.POSTGRES_DATABASE
INFO Creating output ref=output.POSTGRES_PASS
INFO Creating output ref=output.POSTGRES_USER
INFO Building image context=/home/nicj/go/src/github.com/hashicraft/fabric-microservices-mod/jumppad/minecraft/Docker dockerfile=Dockerfile image=jumppad.dev/localcache/minecraft_dev:WJy4LO-l
INFO Creating Network ref=resource.network.local
INFO Generating template ref=resource.template.db_username checksum="" source=postgres output=/home/nicj/.jumppad/data/db_secrets/username
INFO Generating template ref=resource.template.db_password checksum="" source=postgres output=/home/nicj/.jumppad/data/db_secrets/password
INFO Creating Container ref=resource.container.postgres
INFO Creating Container ref=resource.container.minecraft
INFO Creating output ref=output.POSTGRES_ADDR

fabric-microservices-mod's People

Contributors

nicholasjackson avatar

Stargazers

Conrad Parker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.