Skip to content

Commit

Permalink
fix tests, add warning docs, add volatility
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Sep 4, 2024
1 parent c7b27ae commit c1a0ccd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
16 changes: 16 additions & 0 deletions schema/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,20 @@ type MethodDescriptor struct {
// In this case, adding new output fields is an INCOMPATIBLE change (because protobuf service definitions
// don't allow this), but new fields can be added to the referenced struct if it is unsealed.
OutputFields []Field

// Volatility is the volatility of the method.
Volatility Volatility
}

// Volatility is the volatility of a method.
type Volatility int

const (
// PureVolatility indicates that the method can neither read nor write state.
PureVolatility Volatility = iota
// ReadonlyVolatility indicates that the method can read state but not write state.
ReadonlyVolatility

// VolatileVolatility indicates that the method can read and write state.
VolatileVolatility
)
6 changes: 4 additions & 2 deletions schema/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ type Field struct {
ReferencedType string `json:"referenced_type,omitempty"`

// ElementKind is the element type when Kind is ListKind.
ElementKind Kind
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
ElementKind Kind `json:"element_kind,omitempty"`

// Size specifies the size or max-size of a field.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// Its specific meaning may vary depending on the field kind.
// For IntNKind and UintNKind fields, it specifies the bit width of the field.
// For StringKind, BytesKind, AddressKind, and JSONKind, fields it specifies the maximum length rather than a fixed length.
// If it is 0, such fields have no maximum length.
// It is invalid to have a non-zero Size for other kinds.
Size uint32
Size uint32 `json:"size,omitempty"`
}

// Validate validates the field.
Expand Down
10 changes: 5 additions & 5 deletions schema/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const (

// UIntNKind represents a signed integer type with a width in bits specified by the Size field in the
// field definition.
// This is currently UNIMPLEMENTED, this notice will be removed when support is added.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// N must be a multiple of 8, and it is invalid for N to equal 8, 16, 32, 64 as there are more specific
// types for these widths.
// Go Encoding: []byte where len([]byte) == Size / 8, little-endian encoded.
Expand All @@ -217,7 +217,7 @@ const (

// IntNKind represents an unsigned integer type with a width in bits specified by the Size field in the
// field definition. N must be a multiple of 8.
// This is currently UNIMPLEMENTED, this notice will be removed when support is added.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// N must be a multiple of 8, and it is invalid for N to equal 8, 16, 32, 64 as there are more specific
// types for these widths.
// Go Encoding: []byte where len([]byte) == Size / 8, two's complement little-endian encoded.
Expand All @@ -227,7 +227,7 @@ const (
IntNKind

// StructKind represents a struct object.
// This is currently UNIMPLEMENTED, this notice will be removed when support is added.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// Go Encoding: an array of type []interface{} where each element is of the respective field's kind type.
// JSON Encoding: an object where each key is the field name and the value is the field value.
// Canonically, keys are in alphabetical order with no extra whitespace.
Expand All @@ -237,7 +237,7 @@ const (
StructKind

// OneOfKind represents a field that can be one of a set of types.
// This is currently UNIMPLEMENTED, this notice will be removed when support is added.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// Go Encoding: the anonymous struct { Case string; Value interface{} }, aliased as OneOfValue.
// JSON Encoding: same as the case's struct encoding with "@type" set to the case name.
// Key Binary Encoding: not valid as a key field.
Expand All @@ -246,7 +246,7 @@ const (
OneOfKind

// ListKind represents a list of elements.
// This is currently UNIMPLEMENTED, this notice will be removed when support is added.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
// Go Encoding: an array of type []interface{} where each element is of the respective field's kind type.
// JSON Encoding: an array of values where each element is the field value.
// Canonically, there is no extra whitespace.
Expand Down
1 change: 1 addition & 0 deletions schema/oneof.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package schema

// OneOfType represents a oneof type.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
type OneOfType struct {
// Name is the name of the oneof type. It must conform to the NameFormat regular expression.
Name string
Expand Down
1 change: 1 addition & 0 deletions schema/struct.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package schema

// StructType represents a struct type.
// Support for this is currently UNIMPLEMENTED, this notice will be removed when it is added.
type StructType struct {
// Name is the name of the struct type.
Name string
Expand Down

0 comments on commit c1a0ccd

Please sign in to comment.