Skip to content

Commit 4caf39d

Browse files
committed
Added README fro hasura module with configuration description. Updated default values of hasura config.
1 parent 601cd01 commit 4caf39d

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ type Hasura struct {
6464
type HasuraSource struct {
6565
Name string `yaml:"name" validate:"required"`
6666
DatabaseHost string `yaml:"database_host"`
67-
UsePreparedStatements bool `yaml:"use_prepared_statements" validate:"required"`
68-
IsolationLevel string `yaml:"isolation_level" validate:"required"`
67+
UsePreparedStatements bool `yaml:"use_prepared_statements"`
68+
IsolationLevel string `yaml:"isolation_level"`
6969
}
7070

7171
// UnmarshalYAML -

hasura/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Go wrapper for Hasura metadata methods
2+
3+
Golang's library for registration data source in Hasura service
4+
5+
## Configuration
6+
7+
```yaml
8+
hasura:
9+
url: string # hasura url, required
10+
admin_secret: string # required
11+
select_limit: int
12+
allow_aggregation: bool
13+
source:
14+
name: string # name of data source, required. For more info, [hasura docs](https://hasura.io/docs/latest/api-reference/metadata-api/source/#metadata-pg-add-source-syntax).
15+
database_host: string # host of datasource, if omitted, used host from database config
16+
use_prepared_statements: bool # if set to true the server prepares statement before executing on the source database (default: false)
17+
isolation_level: bool # The transaction isolation level in which the queries made to the source will be run with (options: read-committed | repeatable-read | serializable) (default: read-committed)
18+
add_source: bool # should data source be added?
19+
rest: bool # should REST endpoints be created?
20+
```

hasura/api.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ func (api *API) AddSource(ctx context.Context, hasura *config.Hasura, cfg config
131131

132132
databaseUrl := DatabaseUrl(fmt.Sprintf("postgresql://%s:%s@%s:%d/%s", cfg.User, cfg.Password, host, cfg.Port, cfg.Database))
133133

134+
isolationLevel := "read-committed"
135+
if hasura.Source.IsolationLevel != "" {
136+
isolationLevel = hasura.Source.IsolationLevel
137+
}
138+
134139
req := Request{
135140
Type: "pg_add_source",
136141
Args: map[string]interface{}{
@@ -139,7 +144,7 @@ func (api *API) AddSource(ctx context.Context, hasura *config.Hasura, cfg config
139144
ConnectionInfo: ConnectionInfo{
140145
DatabaseUrl: databaseUrl,
141146
UsePreparedStatements: hasura.Source.UsePreparedStatements,
142-
IsolationLevel: hasura.Source.IsolationLevel,
147+
IsolationLevel: isolationLevel,
143148
},
144149
},
145150
"replace_configuration": true,

0 commit comments

Comments
 (0)