github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/remote/config.go (about) 1 package remote 2 3 import ( 4 "fmt" 5 6 "github.com/asynkron/protoactor-go/actor" 7 "google.golang.org/grpc" 8 ) 9 10 func defaultConfig() *Config { 11 return &Config{ 12 AdvertisedHost: "", 13 DialOptions: []grpc.DialOption{grpc.WithInsecure()}, 14 EndpointWriterBatchSize: 1000, 15 EndpointManagerBatchSize: 1000, 16 EndpointWriterQueueSize: 1000000, 17 EndpointManagerQueueSize: 1000000, 18 Kinds: make(map[string]*actor.Props), 19 MaxRetryCount: 5, 20 } 21 } 22 23 func newConfig(options ...ConfigOption) *Config { 24 config := defaultConfig() 25 for _, option := range options { 26 option(config) 27 } 28 return config 29 } 30 31 // Address returns the address of the remote 32 func (rc Config) Address() string { 33 return fmt.Sprintf("%v:%v", rc.Host, rc.Port) 34 } 35 36 // Configure configures the remote 37 func Configure(host string, port int, options ...ConfigOption) *Config { 38 c := newConfig(options...) 39 c.Host = host 40 c.Port = port 41 42 return c 43 } 44 45 // Config is the configuration for the remote 46 type Config struct { 47 Host string 48 Port int 49 AdvertisedHost string 50 ServerOptions []grpc.ServerOption 51 CallOptions []grpc.CallOption 52 DialOptions []grpc.DialOption 53 EndpointWriterBatchSize int 54 EndpointWriterQueueSize int 55 EndpointManagerBatchSize int 56 EndpointManagerQueueSize int 57 Kinds map[string]*actor.Props 58 MaxRetryCount int 59 }