MCPcopy Index your code
hub / github.com/riverqueue/river / defaultClientIDWithHost

Function defaultClientIDWithHost

client.go:3001–3019  ·  view source on GitHub ↗

Same as the above, but allows host injection for testability.

(startedAt time.Time, host string)

Source from the content-addressed store, hash-verified

2999
3000// Same as the above, but allows host injection for testability.
3001func defaultClientIDWithHost(startedAt time.Time, host string) string {
3002 const maxHostLength = 60
3003
3004 // Truncate degenerately long host names.
3005 host = strings.ReplaceAll(host, ".", "_")
3006 if len(host) > maxHostLength {
3007 host = host[0:maxHostLength]
3008 }
3009
3010 // Dots, hyphens, and colons aren't particularly friendly for double click
3011 // to select (depends on application and configuration), so avoid them all
3012 // in favor of underscores.
3013 //
3014 // Go's time package is really dumb and can't format subseconds without
3015 // using a dot. So use the dot, then replace it with an underscore below.
3016 const rfc3339Compact = "2006_01_02T15_04_05.000000"
3017
3018 return host + "_" + strings.Replace(startedAt.Format(rfc3339Compact), ".", "_", 1)
3019}

Callers 2

defaultClientIDFunction · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…