mirror of https://github.com/dragonflyoss/api.git
parent
4e34212aa9
commit
d46b1e7c9b
File diff suppressed because it is too large
Load Diff
|
@ -1470,22 +1470,22 @@ var _ interface {
|
||||||
ErrorName() string
|
ErrorName() string
|
||||||
} = PeerResultValidationError{}
|
} = PeerResultValidationError{}
|
||||||
|
|
||||||
// Validate checks the field values on PeerTarget with the rules defined in the
|
// Validate checks the field values on AnnounceTaskRequest with the rules
|
||||||
// proto definition for this message. If any rules are violated, the first
|
// defined in the proto definition for this message. If any rules are
|
||||||
// error encountered is returned, or nil if there are no violations.
|
// violated, the first error encountered is returned, or nil if there are no violations.
|
||||||
func (m *PeerTarget) Validate() error {
|
func (m *AnnounceTaskRequest) Validate() error {
|
||||||
return m.validate(false)
|
return m.validate(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateAll checks the field values on PeerTarget with the rules defined in
|
// ValidateAll checks the field values on AnnounceTaskRequest with the rules
|
||||||
// the proto definition for this message. If any rules are violated, the
|
// defined in the proto definition for this message. If any rules are
|
||||||
// result is a list of violation errors wrapped in PeerTargetMultiError, or
|
// violated, the result is a list of violation errors wrapped in
|
||||||
// nil if none found.
|
// AnnounceTaskRequestMultiError, or nil if none found.
|
||||||
func (m *PeerTarget) ValidateAll() error {
|
func (m *AnnounceTaskRequest) ValidateAll() error {
|
||||||
return m.validate(true)
|
return m.validate(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PeerTarget) validate(all bool) error {
|
func (m *AnnounceTaskRequest) validate(all bool) error {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1493,7 +1493,7 @@ func (m *PeerTarget) validate(all bool) error {
|
||||||
var errors []error
|
var errors []error
|
||||||
|
|
||||||
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
||||||
err := PeerTargetValidationError{
|
err := AnnounceTaskRequestValidationError{
|
||||||
field: "TaskId",
|
field: "TaskId",
|
||||||
reason: "value length must be at least 1 runes",
|
reason: "value length must be at least 1 runes",
|
||||||
}
|
}
|
||||||
|
@ -1503,10 +1503,22 @@ func (m *PeerTarget) validate(all bool) error {
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
if m.GetUrl() != "" {
|
||||||
err := PeerTargetValidationError{
|
|
||||||
field: "PeerId",
|
if uri, err := url.Parse(m.GetUrl()); err != nil {
|
||||||
reason: "value length must be at least 1 runes",
|
err = AnnounceTaskRequestValidationError{
|
||||||
|
field: "Url",
|
||||||
|
reason: "value must be a valid URI",
|
||||||
|
cause: err,
|
||||||
|
}
|
||||||
|
if !all {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
errors = append(errors, err)
|
||||||
|
} else if !uri.IsAbs() {
|
||||||
|
err := AnnounceTaskRequestValidationError{
|
||||||
|
field: "Url",
|
||||||
|
reason: "value must be absolute",
|
||||||
}
|
}
|
||||||
if !all {
|
if !all {
|
||||||
return err
|
return err
|
||||||
|
@ -1514,19 +1526,133 @@ func (m *PeerTarget) validate(all bool) error {
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.GetUrlMeta() == nil {
|
||||||
|
err := AnnounceTaskRequestValidationError{
|
||||||
|
field: "UrlMeta",
|
||||||
|
reason: "value is required",
|
||||||
|
}
|
||||||
|
if !all {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
errors = append(errors, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if all {
|
||||||
|
switch v := interface{}(m.GetUrlMeta()).(type) {
|
||||||
|
case interface{ ValidateAll() error }:
|
||||||
|
if err := v.ValidateAll(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "UrlMeta",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case interface{ Validate() error }:
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "UrlMeta",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
return AnnounceTaskRequestValidationError{
|
||||||
|
field: "UrlMeta",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if all {
|
||||||
|
switch v := interface{}(m.GetPeerHost()).(type) {
|
||||||
|
case interface{ ValidateAll() error }:
|
||||||
|
if err := v.ValidateAll(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "PeerHost",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case interface{ Validate() error }:
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "PeerHost",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
return AnnounceTaskRequestValidationError{
|
||||||
|
field: "PeerHost",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.GetPiecePacket() == nil {
|
||||||
|
err := AnnounceTaskRequestValidationError{
|
||||||
|
field: "PiecePacket",
|
||||||
|
reason: "value is required",
|
||||||
|
}
|
||||||
|
if !all {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
errors = append(errors, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if all {
|
||||||
|
switch v := interface{}(m.GetPiecePacket()).(type) {
|
||||||
|
case interface{ ValidateAll() error }:
|
||||||
|
if err := v.ValidateAll(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "PiecePacket",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case interface{ Validate() error }:
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
||||||
|
field: "PiecePacket",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if v, ok := interface{}(m.GetPiecePacket()).(interface{ Validate() error }); ok {
|
||||||
|
if err := v.Validate(); err != nil {
|
||||||
|
return AnnounceTaskRequestValidationError{
|
||||||
|
field: "PiecePacket",
|
||||||
|
reason: "embedded message failed validation",
|
||||||
|
cause: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no validation rules for TaskType
|
||||||
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
return PeerTargetMultiError(errors)
|
return AnnounceTaskRequestMultiError(errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PeerTargetMultiError is an error wrapping multiple validation errors
|
// AnnounceTaskRequestMultiError is an error wrapping multiple validation
|
||||||
// returned by PeerTarget.ValidateAll() if the designated constraints aren't met.
|
// errors returned by AnnounceTaskRequest.ValidateAll() if the designated
|
||||||
type PeerTargetMultiError []error
|
// constraints aren't met.
|
||||||
|
type AnnounceTaskRequestMultiError []error
|
||||||
|
|
||||||
// Error returns a concatenation of all the error messages it wraps.
|
// Error returns a concatenation of all the error messages it wraps.
|
||||||
func (m PeerTargetMultiError) Error() string {
|
func (m AnnounceTaskRequestMultiError) Error() string {
|
||||||
var msgs []string
|
var msgs []string
|
||||||
for _, err := range m {
|
for _, err := range m {
|
||||||
msgs = append(msgs, err.Error())
|
msgs = append(msgs, err.Error())
|
||||||
|
@ -1535,11 +1661,11 @@ func (m PeerTargetMultiError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllErrors returns a list of validation violation errors.
|
// AllErrors returns a list of validation violation errors.
|
||||||
func (m PeerTargetMultiError) AllErrors() []error { return m }
|
func (m AnnounceTaskRequestMultiError) AllErrors() []error { return m }
|
||||||
|
|
||||||
// PeerTargetValidationError is the validation error returned by
|
// AnnounceTaskRequestValidationError is the validation error returned by
|
||||||
// PeerTarget.Validate if the designated constraints aren't met.
|
// AnnounceTaskRequest.Validate if the designated constraints aren't met.
|
||||||
type PeerTargetValidationError struct {
|
type AnnounceTaskRequestValidationError struct {
|
||||||
field string
|
field string
|
||||||
reason string
|
reason string
|
||||||
cause error
|
cause error
|
||||||
|
@ -1547,22 +1673,24 @@ type PeerTargetValidationError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field function returns field value.
|
// Field function returns field value.
|
||||||
func (e PeerTargetValidationError) Field() string { return e.field }
|
func (e AnnounceTaskRequestValidationError) Field() string { return e.field }
|
||||||
|
|
||||||
// Reason function returns reason value.
|
// Reason function returns reason value.
|
||||||
func (e PeerTargetValidationError) Reason() string { return e.reason }
|
func (e AnnounceTaskRequestValidationError) Reason() string { return e.reason }
|
||||||
|
|
||||||
// Cause function returns cause value.
|
// Cause function returns cause value.
|
||||||
func (e PeerTargetValidationError) Cause() error { return e.cause }
|
func (e AnnounceTaskRequestValidationError) Cause() error { return e.cause }
|
||||||
|
|
||||||
// Key function returns key value.
|
// Key function returns key value.
|
||||||
func (e PeerTargetValidationError) Key() bool { return e.key }
|
func (e AnnounceTaskRequestValidationError) Key() bool { return e.key }
|
||||||
|
|
||||||
// ErrorName returns error name.
|
// ErrorName returns error name.
|
||||||
func (e PeerTargetValidationError) ErrorName() string { return "PeerTargetValidationError" }
|
func (e AnnounceTaskRequestValidationError) ErrorName() string {
|
||||||
|
return "AnnounceTaskRequestValidationError"
|
||||||
|
}
|
||||||
|
|
||||||
// Error satisfies the builtin error interface
|
// Error satisfies the builtin error interface
|
||||||
func (e PeerTargetValidationError) Error() string {
|
func (e AnnounceTaskRequestValidationError) Error() string {
|
||||||
cause := ""
|
cause := ""
|
||||||
if e.cause != nil {
|
if e.cause != nil {
|
||||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||||
|
@ -1574,14 +1702,14 @@ func (e PeerTargetValidationError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"invalid %sPeerTarget.%s: %s%s",
|
"invalid %sAnnounceTaskRequest.%s: %s%s",
|
||||||
key,
|
key,
|
||||||
e.field,
|
e.field,
|
||||||
e.reason,
|
e.reason,
|
||||||
cause)
|
cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ error = PeerTargetValidationError{}
|
var _ error = AnnounceTaskRequestValidationError{}
|
||||||
|
|
||||||
var _ interface {
|
var _ interface {
|
||||||
Field() string
|
Field() string
|
||||||
|
@ -1589,7 +1717,7 @@ var _ interface {
|
||||||
Key() bool
|
Key() bool
|
||||||
Cause() error
|
Cause() error
|
||||||
ErrorName() string
|
ErrorName() string
|
||||||
} = PeerTargetValidationError{}
|
} = AnnounceTaskRequestValidationError{}
|
||||||
|
|
||||||
// Validate checks the field values on StatTaskRequest with the rules defined
|
// Validate checks the field values on StatTaskRequest with the rules defined
|
||||||
// in the proto definition for this message. If any rules are violated, the
|
// in the proto definition for this message. If any rules are violated, the
|
||||||
|
@ -1859,22 +1987,22 @@ var _ interface {
|
||||||
ErrorName() string
|
ErrorName() string
|
||||||
} = TaskValidationError{}
|
} = TaskValidationError{}
|
||||||
|
|
||||||
// Validate checks the field values on AnnounceTaskRequest with the rules
|
// Validate checks the field values on PeerTarget with the rules defined in the
|
||||||
// defined in the proto definition for this message. If any rules are
|
// proto definition for this message. If any rules are violated, the first
|
||||||
// violated, the first error encountered is returned, or nil if there are no violations.
|
// error encountered is returned, or nil if there are no violations.
|
||||||
func (m *AnnounceTaskRequest) Validate() error {
|
func (m *PeerTarget) Validate() error {
|
||||||
return m.validate(false)
|
return m.validate(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateAll checks the field values on AnnounceTaskRequest with the rules
|
// ValidateAll checks the field values on PeerTarget with the rules defined in
|
||||||
// defined in the proto definition for this message. If any rules are
|
// the proto definition for this message. If any rules are violated, the
|
||||||
// violated, the result is a list of violation errors wrapped in
|
// result is a list of violation errors wrapped in PeerTargetMultiError, or
|
||||||
// AnnounceTaskRequestMultiError, or nil if none found.
|
// nil if none found.
|
||||||
func (m *AnnounceTaskRequest) ValidateAll() error {
|
func (m *PeerTarget) ValidateAll() error {
|
||||||
return m.validate(true)
|
return m.validate(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *AnnounceTaskRequest) validate(all bool) error {
|
func (m *PeerTarget) validate(all bool) error {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1882,7 +2010,7 @@ func (m *AnnounceTaskRequest) validate(all bool) error {
|
||||||
var errors []error
|
var errors []error
|
||||||
|
|
||||||
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
||||||
err := AnnounceTaskRequestValidationError{
|
err := PeerTargetValidationError{
|
||||||
field: "TaskId",
|
field: "TaskId",
|
||||||
reason: "value length must be at least 1 runes",
|
reason: "value length must be at least 1 runes",
|
||||||
}
|
}
|
||||||
|
@ -1892,22 +2020,10 @@ func (m *AnnounceTaskRequest) validate(all bool) error {
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.GetUrl() != "" {
|
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
||||||
|
err := PeerTargetValidationError{
|
||||||
if uri, err := url.Parse(m.GetUrl()); err != nil {
|
field: "PeerId",
|
||||||
err = AnnounceTaskRequestValidationError{
|
reason: "value length must be at least 1 runes",
|
||||||
field: "Url",
|
|
||||||
reason: "value must be a valid URI",
|
|
||||||
cause: err,
|
|
||||||
}
|
|
||||||
if !all {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
errors = append(errors, err)
|
|
||||||
} else if !uri.IsAbs() {
|
|
||||||
err := AnnounceTaskRequestValidationError{
|
|
||||||
field: "Url",
|
|
||||||
reason: "value must be absolute",
|
|
||||||
}
|
}
|
||||||
if !all {
|
if !all {
|
||||||
return err
|
return err
|
||||||
|
@ -1915,133 +2031,19 @@ func (m *AnnounceTaskRequest) validate(all bool) error {
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.GetUrlMeta() == nil {
|
|
||||||
err := AnnounceTaskRequestValidationError{
|
|
||||||
field: "UrlMeta",
|
|
||||||
reason: "value is required",
|
|
||||||
}
|
|
||||||
if !all {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
errors = append(errors, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if all {
|
|
||||||
switch v := interface{}(m.GetUrlMeta()).(type) {
|
|
||||||
case interface{ ValidateAll() error }:
|
|
||||||
if err := v.ValidateAll(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "UrlMeta",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
case interface{ Validate() error }:
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "UrlMeta",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
return AnnounceTaskRequestValidationError{
|
|
||||||
field: "UrlMeta",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if all {
|
|
||||||
switch v := interface{}(m.GetPeerHost()).(type) {
|
|
||||||
case interface{ ValidateAll() error }:
|
|
||||||
if err := v.ValidateAll(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "PeerHost",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
case interface{ Validate() error }:
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "PeerHost",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
return AnnounceTaskRequestValidationError{
|
|
||||||
field: "PeerHost",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.GetPiecePacket() == nil {
|
|
||||||
err := AnnounceTaskRequestValidationError{
|
|
||||||
field: "PiecePacket",
|
|
||||||
reason: "value is required",
|
|
||||||
}
|
|
||||||
if !all {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
errors = append(errors, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if all {
|
|
||||||
switch v := interface{}(m.GetPiecePacket()).(type) {
|
|
||||||
case interface{ ValidateAll() error }:
|
|
||||||
if err := v.ValidateAll(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "PiecePacket",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
case interface{ Validate() error }:
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
||||||
field: "PiecePacket",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if v, ok := interface{}(m.GetPiecePacket()).(interface{ Validate() error }); ok {
|
|
||||||
if err := v.Validate(); err != nil {
|
|
||||||
return AnnounceTaskRequestValidationError{
|
|
||||||
field: "PiecePacket",
|
|
||||||
reason: "embedded message failed validation",
|
|
||||||
cause: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no validation rules for TaskType
|
|
||||||
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
return AnnounceTaskRequestMultiError(errors)
|
return PeerTargetMultiError(errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnounceTaskRequestMultiError is an error wrapping multiple validation
|
// PeerTargetMultiError is an error wrapping multiple validation errors
|
||||||
// errors returned by AnnounceTaskRequest.ValidateAll() if the designated
|
// returned by PeerTarget.ValidateAll() if the designated constraints aren't met.
|
||||||
// constraints aren't met.
|
type PeerTargetMultiError []error
|
||||||
type AnnounceTaskRequestMultiError []error
|
|
||||||
|
|
||||||
// Error returns a concatenation of all the error messages it wraps.
|
// Error returns a concatenation of all the error messages it wraps.
|
||||||
func (m AnnounceTaskRequestMultiError) Error() string {
|
func (m PeerTargetMultiError) Error() string {
|
||||||
var msgs []string
|
var msgs []string
|
||||||
for _, err := range m {
|
for _, err := range m {
|
||||||
msgs = append(msgs, err.Error())
|
msgs = append(msgs, err.Error())
|
||||||
|
@ -2050,11 +2052,11 @@ func (m AnnounceTaskRequestMultiError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllErrors returns a list of validation violation errors.
|
// AllErrors returns a list of validation violation errors.
|
||||||
func (m AnnounceTaskRequestMultiError) AllErrors() []error { return m }
|
func (m PeerTargetMultiError) AllErrors() []error { return m }
|
||||||
|
|
||||||
// AnnounceTaskRequestValidationError is the validation error returned by
|
// PeerTargetValidationError is the validation error returned by
|
||||||
// AnnounceTaskRequest.Validate if the designated constraints aren't met.
|
// PeerTarget.Validate if the designated constraints aren't met.
|
||||||
type AnnounceTaskRequestValidationError struct {
|
type PeerTargetValidationError struct {
|
||||||
field string
|
field string
|
||||||
reason string
|
reason string
|
||||||
cause error
|
cause error
|
||||||
|
@ -2062,24 +2064,22 @@ type AnnounceTaskRequestValidationError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field function returns field value.
|
// Field function returns field value.
|
||||||
func (e AnnounceTaskRequestValidationError) Field() string { return e.field }
|
func (e PeerTargetValidationError) Field() string { return e.field }
|
||||||
|
|
||||||
// Reason function returns reason value.
|
// Reason function returns reason value.
|
||||||
func (e AnnounceTaskRequestValidationError) Reason() string { return e.reason }
|
func (e PeerTargetValidationError) Reason() string { return e.reason }
|
||||||
|
|
||||||
// Cause function returns cause value.
|
// Cause function returns cause value.
|
||||||
func (e AnnounceTaskRequestValidationError) Cause() error { return e.cause }
|
func (e PeerTargetValidationError) Cause() error { return e.cause }
|
||||||
|
|
||||||
// Key function returns key value.
|
// Key function returns key value.
|
||||||
func (e AnnounceTaskRequestValidationError) Key() bool { return e.key }
|
func (e PeerTargetValidationError) Key() bool { return e.key }
|
||||||
|
|
||||||
// ErrorName returns error name.
|
// ErrorName returns error name.
|
||||||
func (e AnnounceTaskRequestValidationError) ErrorName() string {
|
func (e PeerTargetValidationError) ErrorName() string { return "PeerTargetValidationError" }
|
||||||
return "AnnounceTaskRequestValidationError"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error satisfies the builtin error interface
|
// Error satisfies the builtin error interface
|
||||||
func (e AnnounceTaskRequestValidationError) Error() string {
|
func (e PeerTargetValidationError) Error() string {
|
||||||
cause := ""
|
cause := ""
|
||||||
if e.cause != nil {
|
if e.cause != nil {
|
||||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||||
|
@ -2091,14 +2091,14 @@ func (e AnnounceTaskRequestValidationError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"invalid %sAnnounceTaskRequest.%s: %s%s",
|
"invalid %sPeerTarget.%s: %s%s",
|
||||||
key,
|
key,
|
||||||
e.field,
|
e.field,
|
||||||
e.reason,
|
e.reason,
|
||||||
cause)
|
cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ error = AnnounceTaskRequestValidationError{}
|
var _ error = PeerTargetValidationError{}
|
||||||
|
|
||||||
var _ interface {
|
var _ interface {
|
||||||
Field() string
|
Field() string
|
||||||
|
@ -2106,7 +2106,118 @@ var _ interface {
|
||||||
Key() bool
|
Key() bool
|
||||||
Cause() error
|
Cause() error
|
||||||
ErrorName() string
|
ErrorName() string
|
||||||
} = AnnounceTaskRequestValidationError{}
|
} = PeerTargetValidationError{}
|
||||||
|
|
||||||
|
// Validate checks the field values on LeaveHostRequest with the rules defined
|
||||||
|
// in the proto definition for this message. If any rules are violated, the
|
||||||
|
// first error encountered is returned, or nil if there are no violations.
|
||||||
|
func (m *LeaveHostRequest) Validate() error {
|
||||||
|
return m.validate(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateAll checks the field values on LeaveHostRequest with the rules
|
||||||
|
// defined in the proto definition for this message. If any rules are
|
||||||
|
// violated, the result is a list of violation errors wrapped in
|
||||||
|
// LeaveHostRequestMultiError, or nil if none found.
|
||||||
|
func (m *LeaveHostRequest) ValidateAll() error {
|
||||||
|
return m.validate(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LeaveHostRequest) validate(all bool) error {
|
||||||
|
if m == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var errors []error
|
||||||
|
|
||||||
|
if utf8.RuneCountInString(m.GetId()) < 1 {
|
||||||
|
err := LeaveHostRequestValidationError{
|
||||||
|
field: "Id",
|
||||||
|
reason: "value length must be at least 1 runes",
|
||||||
|
}
|
||||||
|
if !all {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
errors = append(errors, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errors) > 0 {
|
||||||
|
return LeaveHostRequestMultiError(errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LeaveHostRequestMultiError is an error wrapping multiple validation errors
|
||||||
|
// returned by LeaveHostRequest.ValidateAll() if the designated constraints
|
||||||
|
// aren't met.
|
||||||
|
type LeaveHostRequestMultiError []error
|
||||||
|
|
||||||
|
// Error returns a concatenation of all the error messages it wraps.
|
||||||
|
func (m LeaveHostRequestMultiError) Error() string {
|
||||||
|
var msgs []string
|
||||||
|
for _, err := range m {
|
||||||
|
msgs = append(msgs, err.Error())
|
||||||
|
}
|
||||||
|
return strings.Join(msgs, "; ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllErrors returns a list of validation violation errors.
|
||||||
|
func (m LeaveHostRequestMultiError) AllErrors() []error { return m }
|
||||||
|
|
||||||
|
// LeaveHostRequestValidationError is the validation error returned by
|
||||||
|
// LeaveHostRequest.Validate if the designated constraints aren't met.
|
||||||
|
type LeaveHostRequestValidationError struct {
|
||||||
|
field string
|
||||||
|
reason string
|
||||||
|
cause error
|
||||||
|
key bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field function returns field value.
|
||||||
|
func (e LeaveHostRequestValidationError) Field() string { return e.field }
|
||||||
|
|
||||||
|
// Reason function returns reason value.
|
||||||
|
func (e LeaveHostRequestValidationError) Reason() string { return e.reason }
|
||||||
|
|
||||||
|
// Cause function returns cause value.
|
||||||
|
func (e LeaveHostRequestValidationError) Cause() error { return e.cause }
|
||||||
|
|
||||||
|
// Key function returns key value.
|
||||||
|
func (e LeaveHostRequestValidationError) Key() bool { return e.key }
|
||||||
|
|
||||||
|
// ErrorName returns error name.
|
||||||
|
func (e LeaveHostRequestValidationError) ErrorName() string { return "LeaveHostRequestValidationError" }
|
||||||
|
|
||||||
|
// Error satisfies the builtin error interface
|
||||||
|
func (e LeaveHostRequestValidationError) Error() string {
|
||||||
|
cause := ""
|
||||||
|
if e.cause != nil {
|
||||||
|
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
key := ""
|
||||||
|
if e.key {
|
||||||
|
key = "key for "
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"invalid %sLeaveHostRequest.%s: %s%s",
|
||||||
|
key,
|
||||||
|
e.field,
|
||||||
|
e.reason,
|
||||||
|
cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ error = LeaveHostRequestValidationError{}
|
||||||
|
|
||||||
|
var _ interface {
|
||||||
|
Field() string
|
||||||
|
Reason() string
|
||||||
|
Key() bool
|
||||||
|
Cause() error
|
||||||
|
ErrorName() string
|
||||||
|
} = LeaveHostRequestValidationError{}
|
||||||
|
|
||||||
// Validate checks the field values on AnnounceHostRequest with the rules
|
// Validate checks the field values on AnnounceHostRequest with the rules
|
||||||
// defined in the proto definition for this message. If any rules are
|
// defined in the proto definition for this message. If any rules are
|
||||||
|
@ -3405,117 +3516,6 @@ var _ interface {
|
||||||
ErrorName() string
|
ErrorName() string
|
||||||
} = BuildValidationError{}
|
} = BuildValidationError{}
|
||||||
|
|
||||||
// Validate checks the field values on LeaveHostRequest with the rules defined
|
|
||||||
// in the proto definition for this message. If any rules are violated, the
|
|
||||||
// first error encountered is returned, or nil if there are no violations.
|
|
||||||
func (m *LeaveHostRequest) Validate() error {
|
|
||||||
return m.validate(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateAll checks the field values on LeaveHostRequest with the rules
|
|
||||||
// defined in the proto definition for this message. If any rules are
|
|
||||||
// violated, the result is a list of violation errors wrapped in
|
|
||||||
// LeaveHostRequestMultiError, or nil if none found.
|
|
||||||
func (m *LeaveHostRequest) ValidateAll() error {
|
|
||||||
return m.validate(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *LeaveHostRequest) validate(all bool) error {
|
|
||||||
if m == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var errors []error
|
|
||||||
|
|
||||||
if utf8.RuneCountInString(m.GetId()) < 1 {
|
|
||||||
err := LeaveHostRequestValidationError{
|
|
||||||
field: "Id",
|
|
||||||
reason: "value length must be at least 1 runes",
|
|
||||||
}
|
|
||||||
if !all {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
errors = append(errors, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(errors) > 0 {
|
|
||||||
return LeaveHostRequestMultiError(errors)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LeaveHostRequestMultiError is an error wrapping multiple validation errors
|
|
||||||
// returned by LeaveHostRequest.ValidateAll() if the designated constraints
|
|
||||||
// aren't met.
|
|
||||||
type LeaveHostRequestMultiError []error
|
|
||||||
|
|
||||||
// Error returns a concatenation of all the error messages it wraps.
|
|
||||||
func (m LeaveHostRequestMultiError) Error() string {
|
|
||||||
var msgs []string
|
|
||||||
for _, err := range m {
|
|
||||||
msgs = append(msgs, err.Error())
|
|
||||||
}
|
|
||||||
return strings.Join(msgs, "; ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllErrors returns a list of validation violation errors.
|
|
||||||
func (m LeaveHostRequestMultiError) AllErrors() []error { return m }
|
|
||||||
|
|
||||||
// LeaveHostRequestValidationError is the validation error returned by
|
|
||||||
// LeaveHostRequest.Validate if the designated constraints aren't met.
|
|
||||||
type LeaveHostRequestValidationError struct {
|
|
||||||
field string
|
|
||||||
reason string
|
|
||||||
cause error
|
|
||||||
key bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Field function returns field value.
|
|
||||||
func (e LeaveHostRequestValidationError) Field() string { return e.field }
|
|
||||||
|
|
||||||
// Reason function returns reason value.
|
|
||||||
func (e LeaveHostRequestValidationError) Reason() string { return e.reason }
|
|
||||||
|
|
||||||
// Cause function returns cause value.
|
|
||||||
func (e LeaveHostRequestValidationError) Cause() error { return e.cause }
|
|
||||||
|
|
||||||
// Key function returns key value.
|
|
||||||
func (e LeaveHostRequestValidationError) Key() bool { return e.key }
|
|
||||||
|
|
||||||
// ErrorName returns error name.
|
|
||||||
func (e LeaveHostRequestValidationError) ErrorName() string { return "LeaveHostRequestValidationError" }
|
|
||||||
|
|
||||||
// Error satisfies the builtin error interface
|
|
||||||
func (e LeaveHostRequestValidationError) Error() string {
|
|
||||||
cause := ""
|
|
||||||
if e.cause != nil {
|
|
||||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
|
||||||
}
|
|
||||||
|
|
||||||
key := ""
|
|
||||||
if e.key {
|
|
||||||
key = "key for "
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"invalid %sLeaveHostRequest.%s: %s%s",
|
|
||||||
key,
|
|
||||||
e.field,
|
|
||||||
e.reason,
|
|
||||||
cause)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ error = LeaveHostRequestValidationError{}
|
|
||||||
|
|
||||||
var _ interface {
|
|
||||||
Field() string
|
|
||||||
Reason() string
|
|
||||||
Key() bool
|
|
||||||
Cause() error
|
|
||||||
ErrorName() string
|
|
||||||
} = LeaveHostRequestValidationError{}
|
|
||||||
|
|
||||||
// Validate checks the field values on PeerPacket_DestPeer with the rules
|
// Validate checks the field values on PeerPacket_DestPeer with the rules
|
||||||
// defined in the proto definition for this message. If any rules are
|
// defined in the proto definition for this message. If any rules are
|
||||||
// violated, the first error encountered is returned, or nil if there are no violations.
|
// violated, the first error encountered is returned, or nil if there are no violations.
|
||||||
|
|
|
@ -187,12 +187,20 @@ message PeerResult{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PeerTarget represents request of LeaveTask.
|
// AnnounceTaskRequest represents request of AnnounceTask.
|
||||||
message PeerTarget{
|
message AnnounceTaskRequest{
|
||||||
// Task id.
|
// Task id.
|
||||||
string task_id = 1 [(validate.rules).string.min_len = 1];
|
string task_id = 1 [(validate.rules).string.min_len = 1];
|
||||||
// Peer id.
|
// Download url.
|
||||||
string peer_id = 2 [(validate.rules).string.min_len = 1];
|
string url = 2 [(validate.rules).string = {uri: true, ignore_empty: true}];
|
||||||
|
// URL meta info.
|
||||||
|
common.UrlMeta url_meta = 3 [(validate.rules).message.required = true];
|
||||||
|
// Peer host info.
|
||||||
|
PeerHost peer_host = 4;
|
||||||
|
// Task piece info.
|
||||||
|
common.PiecePacket piece_packet = 5 [(validate.rules).message.required = true];
|
||||||
|
// Task type.
|
||||||
|
common.TaskType task_type = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatTaskRequest represents request of StatTask.
|
// StatTaskRequest represents request of StatTask.
|
||||||
|
@ -219,20 +227,18 @@ message Task{
|
||||||
bool hasAvailablePeer = 7;
|
bool hasAvailablePeer = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnounceTaskRequest represents request of AnnounceTask.
|
// PeerTarget represents request of LeaveTask.
|
||||||
message AnnounceTaskRequest{
|
message PeerTarget{
|
||||||
// Task id.
|
// Task id.
|
||||||
string task_id = 1 [(validate.rules).string.min_len = 1];
|
string task_id = 1 [(validate.rules).string.min_len = 1];
|
||||||
// Download url.
|
// Peer id.
|
||||||
string url = 2 [(validate.rules).string = {uri: true, ignore_empty: true}];
|
string peer_id = 2 [(validate.rules).string.min_len = 1];
|
||||||
// URL meta info.
|
}
|
||||||
common.UrlMeta url_meta = 3 [(validate.rules).message.required = true];
|
|
||||||
// Peer host info.
|
// LeaveHostRequest represents request of LeaveHost.
|
||||||
PeerHost peer_host = 4;
|
message LeaveHostRequest{
|
||||||
// Task piece info.
|
// Host id.
|
||||||
common.PiecePacket piece_packet = 5 [(validate.rules).message.required = true];
|
string id = 1 [(validate.rules).string.min_len = 1];
|
||||||
// Task type.
|
|
||||||
common.TaskType task_type = 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnounceHostRequest represents request of AnnounceHost.
|
// AnnounceHostRequest represents request of AnnounceHost.
|
||||||
|
@ -372,12 +378,6 @@ message Build {
|
||||||
string platform = 4 [(validate.rules).string.min_len = 1];
|
string platform = 4 [(validate.rules).string.min_len = 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeaveHostRequest represents request of LeaveHost.
|
|
||||||
message LeaveHostRequest{
|
|
||||||
// Host id.
|
|
||||||
string id = 1 [(validate.rules).string.min_len = 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scheduler RPC Service.
|
// Scheduler RPC Service.
|
||||||
service Scheduler{
|
service Scheduler{
|
||||||
// RegisterPeerTask registers a peer into task.
|
// RegisterPeerTask registers a peer into task.
|
||||||
|
@ -389,14 +389,14 @@ service Scheduler{
|
||||||
// ReportPeerResult reports downloading result for the peer.
|
// ReportPeerResult reports downloading result for the peer.
|
||||||
rpc ReportPeerResult(PeerResult)returns(google.protobuf.Empty);
|
rpc ReportPeerResult(PeerResult)returns(google.protobuf.Empty);
|
||||||
|
|
||||||
// LeaveTask makes the peer leaving from task.
|
// A peer announces that it has the announced task to other peers.
|
||||||
rpc LeaveTask(PeerTarget)returns(google.protobuf.Empty);
|
rpc AnnounceTask(AnnounceTaskRequest) returns(google.protobuf.Empty);
|
||||||
|
|
||||||
// Checks if any peer has the given task.
|
// Checks if any peer has the given task.
|
||||||
rpc StatTask(StatTaskRequest)returns(Task);
|
rpc StatTask(StatTaskRequest)returns(Task);
|
||||||
|
|
||||||
// A peer announces that it has the announced task to other peers.
|
// LeaveTask makes the peer leaving from task.
|
||||||
rpc AnnounceTask(AnnounceTaskRequest) returns(google.protobuf.Empty);
|
rpc LeaveTask(PeerTarget)returns(google.protobuf.Empty);
|
||||||
|
|
||||||
// AnnounceHost announces host to scheduler.
|
// AnnounceHost announces host to scheduler.
|
||||||
rpc AnnounceHost(AnnounceHostRequest)returns(google.protobuf.Empty);
|
rpc AnnounceHost(AnnounceHostRequest)returns(google.protobuf.Empty);
|
||||||
|
|
Loading…
Reference in New Issue