Newer
Older
- Server is a golang gin framework developed at Go v1.20.08+
- Before running update following files according to environment:
- Update db related config in - `database.json`
- Server requires mongodb database (version 4.4.13)
- To run:
- `go mod tidy`
- `go run main.go`
- To Build:
- To log errors from commandline, prepare build in `Production` mode.
- Set `IS_PRODUCTION = true` in **main.go** file for production build. And create build with below command.
```go
go build -tags prod
```
- `GoTemplate.postman_collection.json` postman collection.
- To check pprof uncomment pprof call from main file.
- Use profiling for your server see the documentation <https://pkg.go.dev/net/http/pprof>
- also after starting pprof server use this command to check profiling
`go tool pprof http://localhost:YOUR_PPROF_PORT/debug/pprof/heap`
- To use jwt authentication and its variables uncomment decodeToken method to access all token variables.
- To get Mysql DB connection using provided json file just uncomment the `InitMysqlDBConnectionUsingJson` method from main file.
- To get sql server connection using provided json file just uncomment the `InitSQLServerConnectionUsingJson` method from main file.
- There are two ways we can get connection object.
1. first is using GetSQLServerDAO() method:
`GetSQLServerDAO()` returns the default sql server connection object.
2. second is using GetSQLServerDAOWithHost("hostName") method:
`GetSQLServerDAOWithHost("hostName")` returns the sql server connection object of specified HostName.
This method is used when we need to get connection object, other than default database.
## Immudb Operations
- To get immudb server connection using provided json file just uncomment the `InitImmuDBConnectionUsingJson` method from main file.
- To get the connection object GetImmuDAOWithHost(coreimmudb.DefaultHostName) method is used.
`GetImmuDAOWithHost(coreimmudb.DefaultHostName)` returns the immudb server connection object of specified HostName. This method is used when we need to get connection object, other than default database.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Note: All Immudb operations' result is in Base64 format.
## database json format
```json
{
"MongoConfig": [
{
"hostName": "CoreStudio",
"server": "localhost",
"port": 27017,
"username": "",
"password": "",
"database": "CoreStudio",
"isDefault": true
}
],
"ImmudbConfig":[{
"hostName": "ImmuDbHost",
"server": "localhost",
"port": 3322,
"database": "",
"username": "",
"password": "",
"isDefault": true
}],
"MysqlConfig": [
{
"hostName": "MySQLHost",
"server": "localhost",
"port": 3306,
"username": "",
"password": "",
"database": "",
"isDefault":true
}
],
"SqlServerConfig": [
{
"connMaxLifetime": 0,
"database": "",
"dbType": "SQLSERVER",
"hostName": "SQLServerHost",
"isDefault": true,
"maxIdleConns": 0,
"maxOpenConns": 2,
"parameters": [],
"password": "",
"port": 65142,
"protocol": "",
"server": "",
"sqlParameters": [
{
"key": "testKey",
"value": "testValue"
},
{
"key": "boolFlag",
"value": "false"
},
{
"key": "intFlag",
"value": "100"
}
],
"username": ""
}
]
}
```