Skip to main content

neoaria commons module for neoaria-backend-generator

Project description

neoaria-commons

This software is one of the systems that form the basis of software produced by NeoAria Co., Ltd.

It mainly aims to provide the foundation for the back-end system, and among the foundations, it focuses on implementing and operating the source system (data, events, search, web socket).

Quick start

It can be installed through pip application.

  • If installing from scratch :: pip install neoaria-commons

  • In case of update :: pip install --upgrade neoaria-commons

How to use

First, after installation, access must be possible through internal Python.

DataSource

The data source class is a class that focuses on integrating and using various data sources. This class is closely related to the configuration and use of MongoDB, MariaDB, Kafka, Solr, and WebSocket, and the initial configuration values ​​must be defined by the system using this class.

Data sources have a total of three types. Fundamentally, it is divided into DataSource, which manages the state of data, EventSource, which processes data events, and SearchSource, which adjusts data to be searched efficiently.\

DataSource

  • MongoDBDataSource

This is a source that is primarily intended to store and update the state of a specific object, and is the main database for the system currently being built in NeoAria.

  • MariaDBDataSource

Although this source is not currently in active use, it is also a source used for the main purpose of creating and updating the state of data.

EventSource

  • KafkaDataSource

This source is for event processing between external systems and will be the only system that can be used at present.

  • RabbitMQDataSource

Support will be provided later.

SearchSource

  • SolrDataSource

It is a data source that searches data by registering a schema, a series of data models, with the main role of searching through data indexing. It plays an important role in separating and reflecting the existing editing model and service model.

Business

Based on the actual business model, it is composed of BusinessParameter, BusinessResponse, and BusinessCommon and forms a common business.

BusinessParamter

It is a class that transmits parameters for executing a business, and its main purpose is to transmit an object with a Key-Value structure by inheriting BaseModel.

BusinessResponse

Business is a program that ultimately produces results. The main purpose of BusinessResponse is to contain and deliver the results. Like BusinessPrarameter, this also aims to convey values ​​centered on Key-Value.

BusinessCommon

As a common class for all businesses, all businesses must inherit and implement this class. Contains a list of most implementations.

Version History

0.1.0 :

Middleware Configuration

This project now supports middleware configuration through a centralized settings file. The available middleware options include:

  • Logging: Customize logging behavior to track and store application logs.
  • JWT (JSON Web Token): Configure JWT for secure token-based authentication.
  • Gzip Response: Enable gzip compression for responses to improve performance.
  • CORS (Cross-Origin Resource Sharing): Set up CORS policies to control resource sharing between different domains.
  • System Preformance Monitoring for Prometheus: Integrate with Prometheus for system monitoring and metrics collection.

To configure these middleware options, please refer to the settings in the config/middleware.yaml file. Each section of the file corresponds to one of the middleware components, and you can modify the parameters according to your requirements.

The code to use is provided below.

from fastapi import FastAPI
from app.routers import router
from neoaria.middleware import setupMiddleware

app = FastAPI()

setupMiddleware(app)

app.include_router(router.router)

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

And to use it this way, specify it in a similar format in the config/middleware.yaml file within your project folder as follows.

  • The latest version adds the ability to send logs through kafka.
logging:
  enabled: True
  level: 'DEBUG' # DEBUG, INFO, WARNING, ERROR, CRITICAL
  include_headers: True # True, False
  type: kafka # http, syslog, kafka
  format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
  servers:
    http:
      host: localhost
      port: 8080
      endpoint: /log/create
    syslog:
      host: localhost
      port: 514
    kafka:
      producer:
        bootstrap.servers: '192.168.1.100:9091,192.168.1.100:9092,192.168.1.100:9093,192.168.1.100:9094,192.168.1.100:9095'
        client.id: 'token-manager'
        retries: 5
      topic: 'rms.log'
  
jwt:
  enabled: True
  secret_key: '******'
  algorithms: HS256
  targets:
    - /api/v1/*

  
gzip-response:
  enabled: True
  minimum_size: 1024

cors:
  enabled: True
  allow_credentials: True
  allow_origins: ['*']
  allow_methods: ['*']
  allow_headers: ['*']

performance-monitor:
  enabled: True

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neoaria_commons-0.1.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file neoaria_commons-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for neoaria_commons-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cadad0d942284bd0bed564ce27f7d83c863babedc65fabe2dcf911655c91c380
MD5 bd608f3a7e2db6225ac87779e3f015ba
BLAKE2b-256 1864d8195d8226335f2c946b86dd16233ff2546d3a05006a73c8ee49cc982c89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page