Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIsCompatibleRequest(baseURL string, subject Subject, version string, body *SchemaJSON) (*http.Request, error)
- func GetConfigRequest(baseURL string) (*http.Request, error)
- func GetFunctionalTestURL(t *testing.T) string
- func GetSchemaRequest(baseURL string, id uint32) (*http.Request, error)
- func GetSubjectConfigRequest(baseURL string, subject Subject) (*http.Request, error)
- func GetVersionRequest(baseURL string, subject Subject, version string) (*http.Request, error)
- func HandleFunctionalTestError(t testing.TB, err error)
- func HasSchema(client HTTPClient, url string, subject Subject, schema Schema) (version int, id int, err error)
- func HasSchemaRequest(baseURL string, subject Subject, body *SchemaJSON) (*http.Request, error)
- func IsCompatible(client HTTPClient, url string, subject Subject, version string, schema Schema) (is bool, err error)
- func IsFunctionalTestRequired() bool
- func ListSubjectsRequest(baseURL string) (*http.Request, error)
- func ListVersions(client HTTPClient, url string, subject Subject) (versions []int, err error)
- func ListVersionsRequest(baseURL string, subject Subject) (*http.Request, error)
- func PutSubjectConfigRequest(baseURL string, subject Subject, body *ConfigPutJSON) (*http.Request, error)
- func Register(client HTTPClient, url string, subject Subject, schema Schema) (id uint32, err error)
- func RegisterRequest(baseURL string, subject Subject, body *SchemaJSON) (*http.Request, error)
- type Compatibility
- func GetDefaultCompatibility(client HTTPClient, url string) (compatibility Compatibility, err error)
- func GetSubjectCompatibility(client HTTPClient, url string, subject Subject) (compatibility Compatibility, err error)
- func GetSubjectDerivedCompatibility(client HTTPClient, url string, subject Subject) (compatibility Compatibility, err error)
- func SetSubjectCompatibility(client HTTPClient, url string, subject Subject, compatibility Compatibility) (result Compatibility, err error)
- type ConfigGetJSON
- type ConfigPutJSON
- type HTTPClient
- type Schema
- func GetLatestSchema(client HTTPClient, url string, subject Subject) (id uint32, schema Schema, err error)
- func GetSchema(client HTTPClient, url string, id uint32) (schema Schema, err error)
- func GetVersion(client HTTPClient, url string, subject Subject, version string) (id uint32, schema Schema, err error)
- func TestSchema(unique int64) Schema
- func UniqueSchema() Schema
- type SchemaJSON
- type Subject
Constants ¶
const ( //Zero is a zero value for compatibility and is not returned by the schema registry Zero = Compatibility("") //None means no compatibility between schemas is expected None = Compatibility("NONE") //Full means both Forward and Backward compatibility is expected Full = Compatibility("FULL") //Forward compatibility means all previous schemas can read the compatible schema Forward = Compatibility("FORWARD") //Backward compatibility means the compatible schema can read all previous schemas Backward = Compatibility("BACKWARD") )
const ( //TestURLEnvVar is the url to run functional tests against TestURLEnvVar = "SR_TEST_SCHEMA_REGISTRY" //TestRequiredEnvVar if set to true will make tests fail TestRequiredEnvVar = "SR_TEST_REQUIRED" )
const EmptySubject = Subject("")
EmptySubject is just a place holder for the empty string.
Variables ¶
var EmptySchema = Schema("")
EmptySchema is the 'zero' value for a Schema
Functions ¶
func CheckIsCompatibleRequest ¶
func CheckIsCompatibleRequest(baseURL string, subject Subject, version string, body *SchemaJSON) (*http.Request, error)
CheckIsCompatibleRequest returns the http.Request for the POST /compatibility/subjects/<subject>/versions/<version> route
func GetConfigRequest ¶
GetConfigRequest returns the http.Request for the GET /config route
func GetFunctionalTestURL ¶
GetFunctionalTestURL skips, fails, or returns the config variable passed in
func GetSchemaRequest ¶
GetSchemaRequest returns the http.Request for GET /schemas/ids/<id> route
func GetSubjectConfigRequest ¶
GetSubjectConfigRequest returns the http.Request for the GET /config route
func GetVersionRequest ¶
GetVersionRequest returns the http.Request for the GET /subjects/<subject>/versions/<version> version can either be a number or 'latest'
func HandleFunctionalTestError ¶
HandleFunctionalTestError will skip or fail based on whether SR_TEST_REQUIRED is set
func HasSchema ¶
func HasSchema(client HTTPClient, url string, subject Subject, schema Schema) (version int, id int, err error)
HasSchema returns the version and id for a schema on a subject
func HasSchemaRequest ¶
HasSchemaRequest returns the http.Request for the POST /subjects/<subject>
func IsCompatible ¶
func IsCompatible(client HTTPClient, url string, subject Subject, version string, schema Schema) (is bool, err error)
IsCompatible will return if the provided schema is compatible with the subject and version provided. Version can either be a numeric version or 'latest'
func IsFunctionalTestRequired ¶
func IsFunctionalTestRequired() bool
IsFunctionalTestRequired returns whether SR_TEST_REQUIRED is set
func ListSubjectsRequest ¶
ListSubjectsRequest returns the GET /subjects
func ListVersions ¶
func ListVersions(client HTTPClient, url string, subject Subject) (versions []int, err error)
ListVersions returns the list of versions for a subject
func ListVersionsRequest ¶
ListVersionsRequest returns GET /subjects/<subject>/versions
func PutSubjectConfigRequest ¶
func PutSubjectConfigRequest(baseURL string, subject Subject, body *ConfigPutJSON) (*http.Request, error)
PutSubjectConfigRequest returns the http.Request for the Put /config/<subject> route
func RegisterRequest ¶
RegisterRequest returns the http.Request for the POST /subjects/<subject>/versions
Types ¶
type Compatibility ¶
type Compatibility string
Compatibility is the compatibility level from the schema registry. See schema registry documentation for more details
func GetDefaultCompatibility ¶
func GetDefaultCompatibility(client HTTPClient, url string) (compatibility Compatibility, err error)
GetDefaultCompatibility returns the compatibility level set at the server level
func GetSubjectCompatibility ¶
func GetSubjectCompatibility(client HTTPClient, url string, subject Subject) (compatibility Compatibility, err error)
GetSubjectCompatibility returns the compatibility level for a subject
func GetSubjectDerivedCompatibility ¶
func GetSubjectDerivedCompatibility(client HTTPClient, url string, subject Subject) (compatibility Compatibility, err error)
GetSubjectDerivedCompatibility returns the compatibility level for a subject or the default if a subject specific doesnt exist
func SetSubjectCompatibility ¶
func SetSubjectCompatibility(client HTTPClient, url string, subject Subject, compatibility Compatibility) (result Compatibility, err error)
SetSubjectCompatibility sets the compatibility level for a subject
type ConfigGetJSON ¶
type ConfigGetJSON struct {
Compatibility string `json:"compatibilityLevel"`
}
ConfigGetJSON is what the schema registry returns on config get endpoints
type ConfigPutJSON ¶
type ConfigPutJSON struct {
Compatibility string `json:"compatibility"`
}
ConfigPutJSON is what the schema registry expects on config put endpoints
type HTTPClient ¶
HTTPClient is any client that can do a http request
type Schema ¶
type Schema string
Schema is a string that represents a avro schema
func GetLatestSchema ¶
func GetLatestSchema(client HTTPClient, url string, subject Subject) (id uint32, schema Schema, err error)
GetLatestSchema returns the latest schema and id for a subject
func GetSchema ¶
func GetSchema(client HTTPClient, url string, id uint32) (schema Schema, err error)
GetSchema returns a schema for an id
func GetVersion ¶
func GetVersion(client HTTPClient, url string, subject Subject, version string) (id uint32, schema Schema, err error)
GetVersion returns a schema and id for a subject and version
func TestSchema ¶
TestSchema returns a schema with the unique part added to the name
type SchemaJSON ¶
type SchemaJSON struct {
Schema Schema `json:"schema"`
}
SchemaJSON is what the schema registry expects when sending it a schema
type Subject ¶
type Subject string
Subject is *not* a topic. Subject is a schema registry abstraction, topic is a kafka one. For instance the kafka rest proxy assumes that for topic "foo" there can be 2 subjects foo-key and foo-value. foo-key will store the schema for the key field (if any) and foo-value will store the schema for the value field
func KeySubject ¶
KeySubject takes a topic name and turns it into what kafka-rest assumes is the name for value schemas
func ListSubjects ¶
func ListSubjects(client HTTPClient, url string) (subjects []Subject, err error)
ListSubjects returns the list of subjects
func UniqueSubject ¶
func UniqueSubject() Subject
UniqueSubject returns a subject with a unique name
func ValueSubject ¶
ValueSubject takes a topic name and turns it into what kafka-rest assumes is the name for value schemas