Giter Site home page Giter Site logo

rog-golang-buddies / api-hub_storage-and-update-service Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 1001 KB

API hub service to provide CRUD operations with API definitions and keep data up to date.

License: Apache License 2.0

Dockerfile 1.59% Makefile 2.84% Go 95.58%

api-hub_storage-and-update-service's Introduction

Storage and update service

pre-commit pre-commit.ci status

Description

This service represents API Specification document (ASD) data access interface (RabbitMQ to save/update, gRPC to get). It provides gRPC API to search and get ASD documents, queue event listener to save ASD documents. Also, this service is supposed to update ASD models. (request update from data scraping service)

Main functions (To Do)

Proof of Concept stage

  1. Provide gRPC API with methods:
    • search(search string, page int) (Page[ApiSpecDocShort], error) to search by domain and description. Return a list of short descriptions.
    • get(id long) (ApiSpecDef, error) to get the full API Spec document by id.
  2. Process events from Rabbit MQ with ASD model:
    • retrieve events from Rabbit MQ with ASD model
    • save/update data in DB (set created_at/updated_at)
    • notify API Gateway on update if required (event need to contain flag - is notification needed)
  3. Check last updated dates and request update if necessary:
    • get expiration time from the environment variable
    • perform periodically task and get records that require update
    • send them to data scraper service with queue

Future plans

  1. Add caching.

Data flows involving service

  1. Usual UI request (search/get) API Gateway -gRPC-> storage and update service -> DB
  2. Add new/update existing ASD data scraper service -RabbitMQ-> storage and update service (-RabbitMQ->, -RabbitMQ->) (API Gateway, DB)
  3. Update stale data storage and update service -RabbitMQ-> data scraper service -RabbitMQ-> storage and update service -> DB

Additional resources

  1. Database schema https://dbdiagram.io/d/630287b1f1a9b01b0fb26570 / https://imgur.com/a/evcpXry

api-hub_storage-and-update-service's People

Contributors

alexs778 avatar dependabot[bot] avatar ldmi3i avatar pre-commit-ci[bot] avatar

api-hub_storage-and-update-service's Issues

Create ApiSpecDoc event listener

This service is supposed to retrieve ApiSpecDoc models from storage and update the service.
The message body will also contain a flag - is notification required.

Here you need to create a RabbitMQ event listener similar to task rog-golang-buddies/api-hub_data-scraping-service#11 .
EventListener has to retrieve a message from the queue and pass it to some update service method (currently you may just add a comment to the place where the method should be called, have to be created in the issue #8 ).

Create proto files and generate server code.

Create .proto files with API methods to search and retrieve ApiSpecDocs

  1. Search
  2. Get by Id

As base representation for the full view, you have to use copied model from the issue #6
(take a look readme for the details)

Fix/Setup pipelines to docker hub.

Currently pipeline fails due to absence of variables for sonar auth.
Also need to add required data to provide building and pushing image to docker hub.

Add base infrastructure

You need to add base interfaces and project structure to provide the possibility to:

  1. Update ApiSpecDoc - check if that model is really new, and if it is - calls update in DB.
  2. Add middleware (in the future probably will contain cache) and services to search and get ApiSpecDoc.
  3. Add entities and repositories draft.

(probably we'll need some discussion here, but we need some draft to start)

Choose database

We need to choose database for storage and update service.
I don't see some specific requirements. Db is supposed to provide quite simple actions.
I propose mongodb as more "cloud friendly" (cause of shared architecture).

Database setup

Here you need:

  1. Add database configuration properties.
  2. Add gorm db connection with the postgresql driver.
  3. Add db connection at the application startup (internal/app.go)
  4. Add Postgres db container to docker/docker-compose-dev file and check that connection establish successfully.
  5. Setup migration mechanism using go-migrate.

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.