diff --git a/library/go/core/log/fields.go b/library/go/core/log/fields.go index b30b46a5..f93e7cfc 100644 --- a/library/go/core/log/fields.go +++ b/library/go/core/log/fields.go @@ -49,6 +49,8 @@ const ( FieldTypeContext // FieldTypeLazyCall wraps function to lazy evaluate it after log level confirm FieldTypeLazyCall + // FieldTypeStringer is for fmt.Stringer + FieldTypeStringer fieldTypeLast // service type for testing purposes ) @@ -166,6 +168,8 @@ func (f Field) Any() interface{} { return f.Interface() case FieldTypeLazyCall: return f.Interface() + case FieldTypeStringer: + return f.Interface() default: // For when new field type is not added to this func panic(fmt.Sprintf("unknown field type: %d", f.Type())) @@ -182,6 +186,11 @@ func String(key, value string) Field { return Field{key: key, ftype: FieldTypeString, string: value} } +// Stringer constructs field from fmt.Stringer interface +func Stringer(key string, value fmt.Stringer) Field { + return Field{key: key, ftype: FieldTypeStringer, iface: value} +} + // Sprintf constructs field of string type with formatting func Sprintf(key, format string, args ...interface{}) Field { return Field{key: key, ftype: FieldTypeString, string: fmt.Sprintf(format, args...)} diff --git a/library/go/core/log/zap/zapify.go b/library/go/core/log/zap/zapify.go index d5d4b0ab..57ee93d8 100644 --- a/library/go/core/log/zap/zapify.go +++ b/library/go/core/log/zap/zapify.go @@ -80,6 +80,8 @@ func zapifyField(field log.Field) zap.Field { return zap.Reflect(field.Key(), field.Interface()) case log.FieldTypeByteString: return zap.ByteString(field.Key(), field.Binary()) + case log.FieldTypeStringer: + return zap.Stringer(field.Key(), field.Interface().(fmt.Stringer)) case log.FieldTypeContext: return Context(field.Interface().(context.Context)) case log.FieldTypeLazyCall: diff --git a/transfer_manager/go/pkg/abstract/runtime.go b/transfer_manager/go/pkg/abstract/runtime.go index 59f1f468..16ed679c 100644 --- a/transfer_manager/go/pkg/abstract/runtime.go +++ b/transfer_manager/go/pkg/abstract/runtime.go @@ -22,7 +22,6 @@ const ( ) type Runtime interface { - isRuntime() NeedRestart(runtime Runtime) bool WithDefaults() Validate() error @@ -47,6 +46,10 @@ func NewRuntime(runtime RuntimeType, runtimeSpec string) (Runtime, error) { } } +func RegisterRuntime(r RuntimeType, f func(spec string) (Runtime, error)) { + knownRuntimes[r] = f +} + // Parallelism params type ShardUploadParams struct { JobCount int //Workers count @@ -65,7 +68,6 @@ func DefaultShardUploadParams() *ShardUploadParams { } type ShardingTaskRuntime interface { - isShardingEnabled() WorkersNum() int ThreadsNumPerWorker() int CurrentJobIndex() int diff --git a/transfer_manager/go/pkg/metering/metric.go b/transfer_manager/go/pkg/metering/metric.go index 0d2d20e8..f44c8e89 100644 --- a/transfer_manager/go/pkg/metering/metric.go +++ b/transfer_manager/go/pkg/metering/metric.go @@ -37,7 +37,6 @@ type Metric interface { } type MetricState interface { - isMetricState() Serialize(baseOpts *MeteringOpts) (map[MetricSchema][]string, error) }