mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
115 lines
3.1 KiB
Go
115 lines
3.1 KiB
Go
package temporal
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"slices"
|
|
|
|
"go.temporal.io/server/client"
|
|
"go.temporal.io/server/common/authorization"
|
|
"go.temporal.io/server/common/config"
|
|
"go.temporal.io/server/common/dynamicconfig"
|
|
"go.temporal.io/server/common/log"
|
|
"go.temporal.io/server/common/membership/static"
|
|
"go.temporal.io/server/common/metrics"
|
|
persistenceClient "go.temporal.io/server/common/persistence/client"
|
|
"go.temporal.io/server/common/persistence/visibility"
|
|
"go.temporal.io/server/common/primitives"
|
|
"go.temporal.io/server/common/resolver"
|
|
"go.temporal.io/server/common/rpc/encryption"
|
|
"go.temporal.io/server/common/searchattribute"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type (
|
|
synchronizationModeParams struct {
|
|
blockingStart bool
|
|
interruptCh <-chan interface{}
|
|
}
|
|
|
|
serverOptions struct {
|
|
serviceNames map[primitives.ServiceName]struct{}
|
|
|
|
config *config.Config
|
|
configDir string
|
|
env string
|
|
zone string
|
|
hostsByService map[primitives.ServiceName]static.Hosts
|
|
|
|
startupSynchronizationMode synchronizationModeParams
|
|
|
|
logger log.Logger
|
|
namespaceLogger log.Logger
|
|
authorizer authorization.Authorizer
|
|
tlsConfigProvider encryption.TLSConfigProvider
|
|
claimMapper authorization.ClaimMapper
|
|
audienceGetter authorization.JWTAudienceMapper
|
|
persistenceServiceResolver resolver.ServiceResolver
|
|
elasticsearchHttpClient *http.Client
|
|
dynamicConfigClient dynamicconfig.Client
|
|
customDataStoreFactory persistenceClient.AbstractDataStoreFactory
|
|
customVisibilityStoreFactory visibility.VisibilityStoreFactory
|
|
clientFactoryProvider client.FactoryProvider
|
|
searchAttributesMapper searchattribute.Mapper
|
|
customFrontendInterceptors []grpc.UnaryServerInterceptor
|
|
metricHandler metrics.Handler
|
|
}
|
|
)
|
|
|
|
func newServerOptions(opts []ServerOption) *serverOptions {
|
|
so := &serverOptions{
|
|
// Set defaults here.
|
|
persistenceServiceResolver: resolver.NewNoopResolver(),
|
|
}
|
|
for _, opt := range opts {
|
|
opt.apply(so)
|
|
}
|
|
|
|
return so
|
|
}
|
|
|
|
func (so *serverOptions) loadAndValidate() error {
|
|
for serviceName := range so.serviceNames {
|
|
if !slices.Contains(Services, string(serviceName)) {
|
|
return fmt.Errorf("invalid service %q in service list %v", serviceName, so.serviceNames)
|
|
}
|
|
}
|
|
|
|
if so.config == nil {
|
|
err := so.loadConfig()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to load config: %w", err)
|
|
}
|
|
}
|
|
|
|
err := so.validateConfig()
|
|
if err != nil {
|
|
return fmt.Errorf("config validation error: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (so *serverOptions) loadConfig() error {
|
|
so.config = &config.Config{}
|
|
err := config.Load(so.env, so.configDir, so.zone, so.config)
|
|
if err != nil {
|
|
return fmt.Errorf("config file corrupted: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (so *serverOptions) validateConfig() error {
|
|
if err := so.config.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
for name := range so.serviceNames {
|
|
if _, ok := so.config.Services[string(name)]; !ok {
|
|
return fmt.Errorf("%q service is missing in config", name)
|
|
}
|
|
}
|
|
return nil
|
|
}
|