-
Notifications
You must be signed in to change notification settings - Fork 52
Configurations
Configs: Configuration that is used for the creating required project.This configuration is generated by the end user through CLI.The name of the config file is decided by the user , as user creates the file and apply it using readyGo CLI.
-
The documentation convers sample configurations for http & grpc services.
-
The below is the simple json configuration for http & mongo project.
{
"version": "0.1",
"kind": "http",
"project": "contacts",
"databaseSpec": {
"kind":"nosql",
"name": "mongo",
"connectionString": "mongodb://localhost:27017",
"dbName": "contacts"
},
"apiSpec": {
"kind": "http",
"port": "50058",
"version": "v1"
},
"models": [
{
"name": "person",
"fields": [
{
"name": "name",
"type": "string",
"isKey": true
},
{
"name": "email",
"type": "string",
"isKey": true,
"validateExp": "^[a-zA-Z0-9.!#$%&'*+\\\\/=?^_\\\\`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
},
{
"name": "gender",
"type": "string"
},
{
"name": "contact",
"type": "long"
},
{
"name": "status",
"type": "global.GetDefaultStr(`active`)"
},
{
"name": "lastModified",
"type": "global.GetCurrentDateTimeInStr()"
},
{
"name": "Address",
"type": "Address"
}
]
},
{
"name": "Address",
"fields": [
{
"name": "addressline",
"type": "string"
},
{
"name": "street",
"type": "string"
},
{
"name": "state",
"type": "string"
},
{
"name": "country",
"type": "string"
},
{
"name": "zip",
"type": "string"
}
]
}
]
}
---
version: '0.1'
kind: http
project: contacts
databaseSpec:
kind: nosql
name: mongo
connectionString: mongodb://localhost:27017
dbName: contacts
apiSpec:
kind: http
port: '50058'
version: v1
models:
- name: person
fields:
- name: name
type: string
isKey: true
- name: email
type: string
isKey: true
validateExp: "^[a-zA-Z0-9.!#$%&'*+\\\\/=?^_\\\\`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
- name: gender
type: string
- name: contact
type: long
- name: status
type: global.GetDefaultStr(`active`)
- name: lastModified
type: global.GetCurrentDateTimeInStr()
- name: Address
type: Address
- name: Address
fields:
- name: addressline
type: string
- name: street
type: string
- name: state
type: string
- name: country
type: string
- name: zip
type: string
{
"version": "0.1",
"kind": "http",
"project": "mysqlsample",
"databaseSpec": {
"kind": "sql",
"name":"mysql",
"connectionString": "root:mysql@123@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local",
"dbName": "sample"
},
"apiSpec": {
"kind": "http",
"port": "50059",
"version": "v1"
},
"models": [
{
"name": "person",
"fields": [
{
"name": "name",
"type": "string",
"isKey": true
},
{
"name": "email",
"type": "string",
"validateExp": "[a-zA-Z0-9]",
"isKey": true
},
{
"name": "mobile",
"type": "string"
},
{
"name": "status",
"type": "string"
},
{
"name": "lastModified",
"type": "string"
}
]
}
]
}
---
version: '0.1'
kind: http
project: mysqlsample
databaseSpec:
kind: sql
name: mysql
connectionString: root:mysql@123@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local
dbName: sample
apiSpec:
kind: http
port: '50059'
version: v1
models:
- name: person
fields:
- name: name
type: string
isKey: true
- name: email
type: string
validateExp: "[a-zA-Z0-9]"
isKey: true
- name: mobile
type: string
- name: status
type: string
- name: lastModified
type: string
{
"version": "0.1",
"kind": "grpc",
"project": "grpcsample",
"databaseSpec": {
"kind":"nosql",
"name": "mongo",
"connectionString": "mongodb://localhost:27017",
"dbName": "sample"
},
"apiSpec": {
"kind": "grpc",
"port": "50057",
"version": "v1"
},
"models": [
{
"name": "person",
"fields": [
{
"name": "name",
"type": "string",
"isKey": true
},
{
"name": "govtNo",
"type": "long"
},
{
"name": "isIndian",
"type": "bool"
},
{
"name": "email",
"type": "string",
"validateExp": "[a-zA-Z0-9]",
"isKey": true
},
{
"name": "mobile",
"type": "string"
},
{
"name": "status",
"type": "string"
},
{
"name": "lastModified",
"type": "global.GetCurrentDateTimeInStr()"
}
]
}
]
}
---
version: '0.1'
kind: grpc
project: grpcsample
databaseSpec:
kind: nosql
name: mongo
connectionString: mongodb://localhost:27017
dbName: sample
apiSpec:
kind: grpc
port: '50057'
version: v1
models:
- name: person
fields:
- name: name
type: string
isKey: true
- name: govtNo
type: long
- name: isIndian
type: bool
- name: email
type: string
validateExp: "[a-zA-Z0-9]"
isKey: true
- name: mobile
type: string
- name: status
type: string
- name: lastModified
type: global.GetCurrentDateTimeInStr()
json to yaml conversion online. The credit goes to https://www.json2yaml.com/
-
All valid, example configuration files are located here https://github.com/JitenPalaparthi/readyGo/tree/main/misc/test_configs
-
Even though "version" is given in the above json and yaml file, as of now there is no schema validation against any versions of the file.
-
kind: This is to define, what kind of output project that this configuration is for. Example http | grpc | cloudEvent etc.
-
project: The name of the output project.
-
databaseSpec: This specs is to define database related specs. Like database connection information and name of the database.
-
apiSpec: This specs is to define http | grpc | cloudEvent specs. If http what is the port that it has to use , what is the api version that has to be maintained etc.
-
models: This is to define all models that are going to be used in the project. Model is a key component in this project as based on model the who project is designed. You can create as many models as required.
-
name: Name of the model. It should be a valid GoLang identifier. If not the linter returns the error during generation. The first letter is automatically taken as upper-case even it is defined in lower-case.
-
fields: This is to define all fields for model.
-
name: Name of the filed in the model.It must be a valid go identifier.If not the linter returns the error during generation. The first letter is automatically taken as upper-case even it is defined in lower-case.
-
type: Type of the field. Currently it supports only go primitive types. string, int , float32 etc.
-
isKey: This is to define whether this particular field is a key field. That means while generating database methods, *readyGo creates a special method so that this any record with this field cannot be re-created or updated. Ensures to maintain unique record. User can create as many isKey=true fields as required.
-
validateExp: This is to add in the Validation logic for this model.User has to give respective regular expression in order it to validate. RegEx must be go specific.
-
-