Skip to content

Commit

Permalink
add get global config
Browse files Browse the repository at this point in the history
  • Loading branch information
spaghettifunk committed Apr 18, 2020
1 parent 5b3d1ab commit 46836f2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion schemaregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,21 @@ func (c *Client) GetLatestSchema(subject string) (Schema, error) {
return c.getSubjectSchemaAtVersion(subject, SchemaLatestVersion)
}

// getGlobalConfig returns the default compatibility level of the schema registry
func (c *Client) getGlobalConfig() (Config, error) {
var err error
var config = Config{}

resp, respErr := c.do(http.MethodGet, "/config", "", nil)
if respErr != nil && respErr.(ResourceError).ErrorCode != 404 {
return config, respErr
}
if resp != nil {
err = c.readJSON(resp, &config)
}
return config, err
}

// getConfigSubject returns the Config of global or for a given subject. It handles 404 error in a
// different way, since not-found for a subject configuration means it's using global.
func (c *Client) getConfigSubject(subject string) (Config, error) {
Expand All @@ -618,7 +633,6 @@ func (c *Client) getConfigSubject(subject string) (Config, error) {
if resp != nil {
err = c.readJSON(resp, &config)
}

return config, err
}

Expand Down Expand Up @@ -650,6 +664,11 @@ func (c *Client) GetConfig(subject string) (Config, error) {
return c.getConfigSubject(subject)
}

// GetGlobalConfig returns the global compatibility level of the schema registry
func (c *Client) GetGlobalConfig() (Config, error) {
return c.getGlobalConfig()
}

// SetConfig sets the configuration (Config type) for global Schema-Registry or a specific
// subject. When Config returned has "compatibilityLevel" empty, it's using global settings.
func (c *Client) SetConfig(subject, level string) error {
Expand Down

0 comments on commit 46836f2

Please sign in to comment.