golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.55k stars 17.61k forks source link

x/build/maintner: refactor out gcs and api from maintnerd #24786

Closed broady closed 6 years ago

broady commented 6 years ago

I want to create a customized maintnerd (one feature is being able to add tracked repos while the daemon is running).

Here's a small proposal to make that more possible:

maintnerd then becomes a 500 line program that uses the maintnerapi package, which looks like this:

PACKAGE DOCUMENTATION

package maintnerapi
    import "."

FUNCTIONS

func NewAPIService(corpus *maintner.Corpus) apipb.MaintnerServiceServer

TYPES

type GCSLog struct {
    // contains filtered or unexported fields
}

func NewGCSLog(ctx context.Context, bucketName string) (*GCSLog, error)

func (gl *GCSLog) CopyFrom(src maintner.MutationSource) error
    CopyFrom is only used for the one-time migrate from disk-to-GCS code
    path.

func (gl *GCSLog) GetMutations(ctx context.Context) <-chan maintner.MutationStreamEvent

func (gl *GCSLog) Log(m *maintpb.Mutation) error

func (gl *GCSLog) ServeJSONLogsIndex(w http.ResponseWriter, r *http.Request)

func (gl *GCSLog) ServeLogFile(w http.ResponseWriter, r *http.Request)
broady commented 6 years ago

/cc @bradfitz @andybons @shurcooL

gopherbot commented 6 years ago

Change https://golang.org/cl/105935 mentions this issue: maintner: refactor API into its own package

dmitshur commented 6 years ago

Would this affect the users of golang.org/x/build/maintner/godata package?

bradfitz commented 6 years ago

I want to create a customized maintnerd (one feature is being able to add tracked repos while the daemon is running).

Curious... why?

broady commented 6 years ago

@shurcooL nope. the only real change is moving the "apipb" package, but it's only used by maintnerd and maintq.

@bradfitz I'm tracking dozens/hundreds of repos in the google, googleapis, GoogleCloudPlatform orgs. several repos get added every week. We don't want to restart maintnerd when a new repo gets tracked. oh, and for better or worse (could/should be a separate process), exposing another handler that serves some summarized data.

bradfitz commented 6 years ago

Okay, SGTM. And I do like the idea of moving GCSLog to its own package.