mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fmt: applies go1.19 fmt
This commit is contained in:
parent
849e0478b5
commit
82fbb84384
@ -78,11 +78,11 @@ func Path(configroot, extension string) (string, error) {
|
||||
// Filename returns the configuration file path given a configuration root
|
||||
// directory and a user-provided configuration file path argument with the
|
||||
// following rules:
|
||||
// * If the user-provided configuration file path is empty, use the default one.
|
||||
// * If the configuration root directory is empty, use the default one.
|
||||
// * If the user-provided configuration file path is only a file name, use the
|
||||
// configuration root directory, otherwise use only the user-provided path
|
||||
// and ignore the configuration root.
|
||||
// - If the user-provided configuration file path is empty, use the default one.
|
||||
// - If the configuration root directory is empty, use the default one.
|
||||
// - If the user-provided configuration file path is only a file name, use the
|
||||
// configuration root directory, otherwise use only the user-provided path
|
||||
// and ignore the configuration root.
|
||||
func Filename(configroot string, userConfigFile string) (string, error) {
|
||||
if userConfigFile == "" {
|
||||
return Path(configroot, DefaultConfigFile)
|
||||
|
||||
@ -152,6 +152,7 @@ Set the value of the 'Datastore.Path' key:
|
||||
// A pattern matches a part if and only if the pattern is "*" or the lowercase pattern equals the lowercase part.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// matchesGlobPrefix("foo.bar", []string{"*", "bar", "baz"}) returns true
|
||||
// matchesGlobPrefix("foo.bar.baz", []string{"*", "bar"}) returns true
|
||||
// matchesGlobPrefix("foo.bar", []string{"baz", "*"}) returns false
|
||||
|
||||
@ -5,7 +5,7 @@ Packages underneath core/ provide a (relatively) stable, low-level API
|
||||
to carry out most IPFS-related tasks. For more details on the other
|
||||
interfaces and how core/... fits into the bigger IPFS picture, see:
|
||||
|
||||
$ godoc github.com/ipfs/go-ipfs
|
||||
$ godoc github.com/ipfs/go-ipfs
|
||||
*/
|
||||
package core
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ func maybeProvide(opt interface{}, enable bool) fx.Option {
|
||||
return fx.Options()
|
||||
}
|
||||
|
||||
//nolint unused
|
||||
// nolint unused
|
||||
func maybeInvoke(opt interface{}, enable bool) fx.Option {
|
||||
if enable {
|
||||
return fx.Invoke(opt)
|
||||
|
||||
@ -79,12 +79,12 @@ func (ls loaderState) String() string {
|
||||
// PluginLoader keeps track of loaded plugins.
|
||||
//
|
||||
// To use:
|
||||
// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
|
||||
// will automatically be loaded.
|
||||
// 2. Call Initialize to run all initialization logic.
|
||||
// 3. Call Inject to register the plugins.
|
||||
// 4. Optionally call Start to start plugins.
|
||||
// 5. Call Close to close all plugins.
|
||||
// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
|
||||
// will automatically be loaded.
|
||||
// 2. Call Initialize to run all initialization logic.
|
||||
// 3. Call Inject to register the plugins.
|
||||
// 4. Optionally call Start to start plugins.
|
||||
// 5. Call Close to close all plugins.
|
||||
type PluginLoader struct {
|
||||
state loaderState
|
||||
plugins map[string]plugin.Plugin
|
||||
|
||||
@ -39,11 +39,13 @@ type plEvent struct {
|
||||
// Log all the PeerIDs. This is considered internal, unsupported, and may break at any point.
|
||||
//
|
||||
// Usage:
|
||||
// GOLOG_FILE=~/peer.log IPFS_LOGGING_FMT=json ipfs daemon
|
||||
// Output:
|
||||
// {"level":"info","ts":"2020-02-10T13:54:26.639Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:51","msg":"connected","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt"}
|
||||
// {"level":"info","ts":"2020-02-10T13:54:59.095Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:56","msg":"identified","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt","agent":"go-ipfs/0.5.0/"}
|
||||
//
|
||||
// GOLOG_FILE=~/peer.log IPFS_LOGGING_FMT=json ipfs daemon
|
||||
//
|
||||
// Output:
|
||||
//
|
||||
// {"level":"info","ts":"2020-02-10T13:54:26.639Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:51","msg":"connected","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt"}
|
||||
// {"level":"info","ts":"2020-02-10T13:54:59.095Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:56","msg":"identified","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt","agent":"go-ipfs/0.5.0/"}
|
||||
type peerLogPlugin struct {
|
||||
enabled bool
|
||||
droppedCount uint64
|
||||
|
||||
@ -2,19 +2,19 @@
|
||||
//
|
||||
// TODO explain the package roadmap...
|
||||
//
|
||||
// .ipfs/
|
||||
// ├── client/
|
||||
// | ├── client.lock <------ protects client/ + signals its own pid
|
||||
// │ ├── ipfs-client.cpuprof
|
||||
// │ └── ipfs-client.memprof
|
||||
// ├── config
|
||||
// ├── daemon/
|
||||
// │ ├── daemon.lock <------ protects daemon/ + signals its own address
|
||||
// │ ├── ipfs-daemon.cpuprof
|
||||
// │ └── ipfs-daemon.memprof
|
||||
// ├── datastore/
|
||||
// ├── repo.lock <------ protects datastore/ and config
|
||||
// └── version
|
||||
// .ipfs/
|
||||
// ├── client/
|
||||
// | ├── client.lock <------ protects client/ + signals its own pid
|
||||
// │ ├── ipfs-client.cpuprof
|
||||
// │ └── ipfs-client.memprof
|
||||
// ├── config
|
||||
// ├── daemon/
|
||||
// │ ├── daemon.lock <------ protects daemon/ + signals its own address
|
||||
// │ ├── ipfs-daemon.cpuprof
|
||||
// │ └── ipfs-daemon.memprof
|
||||
// ├── datastore/
|
||||
// ├── repo.lock <------ protects datastore/ and config
|
||||
// └── version
|
||||
package fsrepo
|
||||
|
||||
// TODO prevent multiple daemons from running
|
||||
|
||||
@ -582,17 +582,17 @@ func (r *FSRepo) BackupConfig(prefix string) (string, error) {
|
||||
// SetConfig updates the FSRepo's config. The user must not modify the config
|
||||
// object after calling this method.
|
||||
// FIXME: There is an inherent contradiction with storing non-user-generated
|
||||
// Go config.Config structures as user-generated JSON nested maps. This is
|
||||
// evidenced by the issue of `omitempty` property of fields that aren't defined
|
||||
// by the user and Go still needs to initialize them to its default (which
|
||||
// is not reflected in the repo's config file, see
|
||||
// https://github.com/ipfs/kubo/issues/8088 for more details).
|
||||
// In general we should call this API with a JSON nested maps as argument
|
||||
// (`map[string]interface{}`). Many calls to this function are forced to
|
||||
// synthesize the config.Config struct from their available JSON map just to
|
||||
// satisfy this (causing incompatibilities like the `omitempty` one above).
|
||||
// We need to comb SetConfig calls and replace them when possible with a
|
||||
// JSON map variant.
|
||||
// Go config.Config structures as user-generated JSON nested maps. This is
|
||||
// evidenced by the issue of `omitempty` property of fields that aren't defined
|
||||
// by the user and Go still needs to initialize them to its default (which
|
||||
// is not reflected in the repo's config file, see
|
||||
// https://github.com/ipfs/kubo/issues/8088 for more details).
|
||||
// In general we should call this API with a JSON nested maps as argument
|
||||
// (`map[string]interface{}`). Many calls to this function are forced to
|
||||
// synthesize the config.Config struct from their available JSON map just to
|
||||
// satisfy this (causing incompatibilities like the `omitempty` one above).
|
||||
// We need to comb SetConfig calls and replace them when possible with a
|
||||
// JSON map variant.
|
||||
func (r *FSRepo) SetConfig(updated *config.Config) error {
|
||||
|
||||
// packageLock is held to provide thread-safety.
|
||||
|
||||
@ -26,7 +26,7 @@ var DownloadDirectory string
|
||||
// is needed because the archive "go-ipfs_v0.7.0_linux-amd64.tar.gz" contains a
|
||||
// binary named "ipfs"
|
||||
//
|
||||
// FetchBinary(ctx, fetcher, "go-ipfs", "v0.7.0", "ipfs", tmpDir)
|
||||
// FetchBinary(ctx, fetcher, "go-ipfs", "v0.7.0", "ipfs", tmpDir)
|
||||
//
|
||||
// If out is a directory, then the binary is written to that directory with the
|
||||
// same name it has inside the archive. Otherwise, the binary file is written
|
||||
@ -178,9 +178,9 @@ func osWithVariant() (string, error) {
|
||||
// Returns the archive path and the base name.
|
||||
//
|
||||
// The ipfs path format is: distribution/version/archiveName
|
||||
// - distribution is the name of a distribution, such as "go-ipfs"
|
||||
// - version is the version to fetch, such as "v0.8.0-rc2"
|
||||
// - archiveName is formatted as name_version_osv-GOARCH.atype, such as
|
||||
// - distribution is the name of a distribution, such as "go-ipfs"
|
||||
// - version is the version to fetch, such as "v0.8.0-rc2"
|
||||
// - archiveName is formatted as name_version_osv-GOARCH.atype, such as
|
||||
// "go-ipfs_v0.8.0-rc2_linux-amd64.tar.gz"
|
||||
//
|
||||
// This would form the path:
|
||||
|
||||
@ -19,8 +19,8 @@ type OnlyOne struct {
|
||||
// that are unique across different concrete Repo implementations,
|
||||
// e.g. by creating a local type:
|
||||
//
|
||||
// type repoKey string
|
||||
// r, err := o.Open(repoKey(path), open)
|
||||
// type repoKey string
|
||||
// r, err := o.Open(repoKey(path), open)
|
||||
//
|
||||
// Call Repo.Close when done.
|
||||
func (o *OnlyOne) Open(key interface{}, open func() (Repo, error)) (Repo, error) {
|
||||
|
||||
90
thirdparty/notifier/notifier.go
vendored
90
thirdparty/notifier/notifier.go
vendored
@ -14,23 +14,21 @@ import (
|
||||
// their own Notifiee interfaces to ensure type-safety
|
||||
// of notifications:
|
||||
//
|
||||
// type RocketNotifiee interface{
|
||||
// Countdown(r Rocket, countdown time.Duration)
|
||||
// LiftedOff(Rocket)
|
||||
// ReachedOrbit(Rocket)
|
||||
// Detached(Rocket, Capsule)
|
||||
// Landed(Rocket)
|
||||
// }
|
||||
//
|
||||
// type RocketNotifiee interface{
|
||||
// Countdown(r Rocket, countdown time.Duration)
|
||||
// LiftedOff(Rocket)
|
||||
// ReachedOrbit(Rocket)
|
||||
// Detached(Rocket, Capsule)
|
||||
// Landed(Rocket)
|
||||
// }
|
||||
type Notifiee interface{}
|
||||
|
||||
// Notifier is a notification dispatcher. It's meant
|
||||
// to be composed, and its zero-value is ready to be used.
|
||||
//
|
||||
// type Rocket struct {
|
||||
// notifier notifier.Notifier
|
||||
// }
|
||||
//
|
||||
// type Rocket struct {
|
||||
// notifier notifier.Notifier
|
||||
// }
|
||||
type Notifier struct {
|
||||
mu sync.RWMutex // guards notifiees
|
||||
nots map[Notifiee]struct{}
|
||||
@ -51,17 +49,16 @@ func RateLimited(limit int) *Notifier {
|
||||
// Notify signs up Notifiee e for notifications. This function
|
||||
// is meant to be called behind your own type-safe function(s):
|
||||
//
|
||||
// // generic function for pattern-following
|
||||
// func (r *Rocket) Notify(n Notifiee) {
|
||||
// r.notifier.Notify(n)
|
||||
// }
|
||||
//
|
||||
// // or as part of other functions
|
||||
// func (r *Rocket) Onboard(a Astronaut) {
|
||||
// r.astronauts = append(r.austronauts, a)
|
||||
// r.notifier.Notify(a)
|
||||
// }
|
||||
// // generic function for pattern-following
|
||||
// func (r *Rocket) Notify(n Notifiee) {
|
||||
// r.notifier.Notify(n)
|
||||
// }
|
||||
//
|
||||
// // or as part of other functions
|
||||
// func (r *Rocket) Onboard(a Astronaut) {
|
||||
// r.astronauts = append(r.austronauts, a)
|
||||
// r.notifier.Notify(a)
|
||||
// }
|
||||
func (n *Notifier) Notify(e Notifiee) {
|
||||
n.mu.Lock()
|
||||
if n.nots == nil { // so that zero-value is ready to be used.
|
||||
@ -74,17 +71,16 @@ func (n *Notifier) Notify(e Notifiee) {
|
||||
// StopNotify stops notifying Notifiee e. This function
|
||||
// is meant to be called behind your own type-safe function(s):
|
||||
//
|
||||
// // generic function for pattern-following
|
||||
// func (r *Rocket) StopNotify(n Notifiee) {
|
||||
// r.notifier.StopNotify(n)
|
||||
// }
|
||||
//
|
||||
// // or as part of other functions
|
||||
// func (r *Rocket) Detach(c Capsule) {
|
||||
// r.notifier.StopNotify(c)
|
||||
// r.capsule = nil
|
||||
// }
|
||||
// // generic function for pattern-following
|
||||
// func (r *Rocket) StopNotify(n Notifiee) {
|
||||
// r.notifier.StopNotify(n)
|
||||
// }
|
||||
//
|
||||
// // or as part of other functions
|
||||
// func (r *Rocket) Detach(c Capsule) {
|
||||
// r.notifier.StopNotify(c)
|
||||
// r.capsule = nil
|
||||
// }
|
||||
func (n *Notifier) StopNotify(e Notifiee) {
|
||||
n.mu.Lock()
|
||||
if n.nots != nil { // so that zero-value is ready to be used.
|
||||
@ -97,22 +93,22 @@ func (n *Notifier) StopNotify(e Notifiee) {
|
||||
// This is done by calling the given function with each notifiee. It is
|
||||
// meant to be called with your own type-safe notification functions:
|
||||
//
|
||||
// func (r *Rocket) Launch() {
|
||||
// r.notifyAll(func(n Notifiee) {
|
||||
// n.Launched(r)
|
||||
// })
|
||||
// }
|
||||
// func (r *Rocket) Launch() {
|
||||
// r.notifyAll(func(n Notifiee) {
|
||||
// n.Launched(r)
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// // make it private so only you can use it. This function is necessary
|
||||
// // to make sure you only up-cast in one place. You control who you added
|
||||
// // to be a notifiee. If Go adds generics, maybe we can get rid of this
|
||||
// // method but for now it is like wrapping a type-less container with
|
||||
// // a type safe interface.
|
||||
// func (r *Rocket) notifyAll(notify func(Notifiee)) {
|
||||
// r.notifier.NotifyAll(func(n notifier.Notifiee) {
|
||||
// notify(n.(Notifiee))
|
||||
// })
|
||||
// }
|
||||
// // make it private so only you can use it. This function is necessary
|
||||
// // to make sure you only up-cast in one place. You control who you added
|
||||
// // to be a notifiee. If Go adds generics, maybe we can get rid of this
|
||||
// // method but for now it is like wrapping a type-less container with
|
||||
// // a type safe interface.
|
||||
// func (r *Rocket) notifyAll(notify func(Notifiee)) {
|
||||
// r.notifier.NotifyAll(func(n notifier.Notifiee) {
|
||||
// notify(n.(Notifiee))
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// Note well: each notification is launched in its own goroutine, so they
|
||||
// can be processed concurrently, and so that whatever the notification does
|
||||
|
||||
@ -8,70 +8,67 @@
|
||||
//
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md
|
||||
//
|
||||
// - OTEL_TRACES_EXPORTER: a comma-separated list of exporters
|
||||
// - otlp
|
||||
// - jaeger
|
||||
// - zipkin
|
||||
// - file
|
||||
// OTEL_TRACES_EXPORTER: a comma-separated list of exporters:
|
||||
// - otlp
|
||||
// - jaeger
|
||||
// - zipkin
|
||||
// - file
|
||||
//
|
||||
// Different exporters have their own set of environment variables, depending on the exporter. These are typically
|
||||
// standard environment variables. Some common ones:
|
||||
//
|
||||
// Jaeger:
|
||||
//
|
||||
// - OTEL_EXPORTER_JAEGER_AGENT_HOST
|
||||
// - OTEL_EXPORTER_JAEGER_AGENT_PORT
|
||||
// - OTEL_EXPORTER_JAEGER_ENDPOINT
|
||||
// - OTEL_EXPORTER_JAEGER_USER
|
||||
// - OTEL_EXPORTER_JAEGER_PASSWORD
|
||||
// - OTEL_EXPORTER_JAEGER_AGENT_HOST
|
||||
// - OTEL_EXPORTER_JAEGER_AGENT_PORT
|
||||
// - OTEL_EXPORTER_JAEGER_ENDPOINT
|
||||
// - OTEL_EXPORTER_JAEGER_USER
|
||||
// - OTEL_EXPORTER_JAEGER_PASSWORD
|
||||
//
|
||||
// OTLP HTTP/gRPC:
|
||||
//
|
||||
// - OTEL_EXPORTER_OTLP_PROTOCOL
|
||||
// - one of [grpc, http/protobuf]
|
||||
// - default: grpc
|
||||
// - OTEL_EXPORTER_OTLP_ENDPOINT
|
||||
// - OTEL_EXPORTER_OTLP_CERTIFICATE
|
||||
// - OTEL_EXPORTER_OTLP_HEADERS
|
||||
// - OTEL_EXPORTER_OTLP_COMPRESSION
|
||||
// - OTEL_EXPORTER_OTLP_TIMEOUT
|
||||
// - OTEL_EXPORTER_OTLP_PROTOCOL
|
||||
// one of [grpc, http/protobuf]
|
||||
// default: grpc
|
||||
// - OTEL_EXPORTER_OTLP_ENDPOINT
|
||||
// - OTEL_EXPORTER_OTLP_CERTIFICATE
|
||||
// - OTEL_EXPORTER_OTLP_HEADERS
|
||||
// - OTEL_EXPORTER_OTLP_COMPRESSION
|
||||
// - OTEL_EXPORTER_OTLP_TIMEOUT
|
||||
//
|
||||
// Zipkin:
|
||||
//
|
||||
// - OTEL_EXPORTER_ZIPKIN_ENDPOINT
|
||||
// - OTEL_EXPORTER_ZIPKIN_ENDPOINT
|
||||
//
|
||||
// File:
|
||||
//
|
||||
// - OTEL_EXPORTER_FILE_PATH
|
||||
// - file path to write JSON traces
|
||||
// - default: `$PWD/traces.json`
|
||||
// - OTEL_EXPORTER_FILE_PATH
|
||||
// file path to write JSON traces
|
||||
// default: `$PWD/traces.json`
|
||||
//
|
||||
// For example, if you run a local IPFS daemon, you can use the jaegertracing/all-in-one Docker image to run
|
||||
// a full Jaeger stack and configure go-ipfs to publish traces to it:
|
||||
//
|
||||
// docker run -d --name jaeger \
|
||||
// -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
|
||||
// -p 5775:5775/udp \
|
||||
// -p 6831:6831/udp \
|
||||
// -p 6832:6832/udp \
|
||||
// -p 5778:5778 \
|
||||
// -p 16686:16686 \
|
||||
// -p 14268:14268 \
|
||||
// -p 14269:14269 \
|
||||
// -p 14250:14250 \
|
||||
// -p 9411:9411 \
|
||||
// jaegertracing/all-in-one
|
||||
// OTEL_TRACES_EXPORTER=jaeger ipfs daemon
|
||||
// docker run -d --name jaeger \
|
||||
// -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
|
||||
// -p 5775:5775/udp \
|
||||
// -p 6831:6831/udp \
|
||||
// -p 6832:6832/udp \
|
||||
// -p 5778:5778 \
|
||||
// -p 16686:16686 \
|
||||
// -p 14268:14268 \
|
||||
// -p 14269:14269 \
|
||||
// -p 14250:14250 \
|
||||
// -p 9411:9411 \
|
||||
// jaegertracing/all-in-one
|
||||
// OTEL_TRACES_EXPORTER=jaeger ipfs daemon
|
||||
//
|
||||
// In this example the Jaeger UI is available at http://localhost:16686.
|
||||
//
|
||||
//
|
||||
// Implementer Notes
|
||||
// # In this example the Jaeger UI is available at http://localhost:16686.
|
||||
//
|
||||
// Span names follow a convention of <Component>.<Span>, some examples:
|
||||
//
|
||||
// - component=Gateway + span=Request -> Gateway.Request
|
||||
// - component=CoreAPI.PinAPI + span=Verify.CheckPin -> CoreAPI.PinAPI.Verify.CheckPin
|
||||
// - component=Gateway + span=Request -> Gateway.Request
|
||||
// - component=CoreAPI.PinAPI + span=Verify.CheckPin -> CoreAPI.PinAPI.Verify.CheckPin
|
||||
//
|
||||
// We follow the OpenTelemetry convention of using whatever TracerProvider is registered globally.
|
||||
package tracing
|
||||
|
||||
Loading…
Reference in New Issue
Block a user