Documentation ¶
Overview ¶
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. CODE ATTRIBUTION: https://github.com/dapr/go-sdk Modified the import package to use layotto's pb We use same sdk code with Dapr's for state API because we want to keep compatible with Dapr state API
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. CODE ATTRIBUTION: https://github.com/dapr/go-sdk Modified the import package to use layotto's pb We use same sdk code with Dapr's for state API because we want to keep compatible with Dapr state API
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. CODE ATTRIBUTION: https://github.com/dapr/go-sdk Modified the import package to use layotto's pb We use same sdk code with Dapr's for state API because we want to keep compatible with Dapr state API
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. CODE ATTRIBUTION: https://github.com/dapr/go-sdk Modified the import package to use layotto's pb We use same sdk code with Dapr's for state API because we want to keep compatible with Dapr state API
Index ¶
- Constants
- func GoWithRecover(handler func(), recoverHandler func(r interface{}))
- func RegisterRecoverLogger(f func(w io.Writer, r interface{}))
- type BulkStateItem
- type Client
- type ConfigurationItem
- type ConfigurationRequestItem
- type DataContent
- type DeleteStateItem
- type ETag
- type GRPCClient
- func (c *GRPCClient) Close()
- func (c *GRPCClient) DeleteBulkState(ctx context.Context, storeName string, keys []string) error
- func (c *GRPCClient) DeleteBulkStateItems(ctx context.Context, storeName string, items []*DeleteStateItem) error
- func (c *GRPCClient) DeleteConfiguration(ctx context.Context, in *ConfigurationRequestItem) error
- func (c *GRPCClient) DeleteState(ctx context.Context, storeName, key string) error
- func (c *GRPCClient) DeleteStateWithETag(ctx context.Context, storeName, key string, etag *ETag, meta map[string]string, ...) error
- func (c *GRPCClient) ExecuteStateTransaction(ctx context.Context, storeName string, meta map[string]string, ...) error
- func (c *GRPCClient) GetBulkSecret(ctx context.Context, in *runtimev1pb.GetBulkSecretRequest, ...) (*runtimev1pb.GetBulkSecretResponse, error)
- func (c *GRPCClient) GetBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string, ...) ([]*BulkStateItem, error)
- func (c *GRPCClient) GetConfiguration(ctx context.Context, in *ConfigurationRequestItem) ([]*ConfigurationItem, error)
- func (c *GRPCClient) GetNextId(ctx context.Context, req *runtimev1pb.GetNextIdRequest) (*runtimev1pb.GetNextIdResponse, error)
- func (c *GRPCClient) GetSecret(ctx context.Context, in *runtimev1pb.GetSecretRequest, opts ...grpc.CallOption) (*runtimev1pb.GetSecretResponse, error)
- func (c *GRPCClient) GetState(ctx context.Context, storeName, key string) (item *StateItem, err error)
- func (c *GRPCClient) GetStateWithConsistency(ctx context.Context, storeName, key string, meta map[string]string, ...) (item *StateItem, err error)
- func (c *GRPCClient) InvokeMethod(ctx context.Context, appID, methodName, verb string) (out []byte, err error)
- func (c *GRPCClient) InvokeMethodWithContent(ctx context.Context, appID, methodName, verb string, content *DataContent) (out []byte, err error)
- func (c *GRPCClient) InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, ...) (out []byte, err error)
- func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error
- func (c *GRPCClient) PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error
- func (c *GRPCClient) SaveBulkState(ctx context.Context, storeName string, items ...*SetStateItem) error
- func (c *GRPCClient) SaveConfiguration(ctx context.Context, in *SaveConfigurationRequest) error
- func (c *GRPCClient) SaveState(ctx context.Context, storeName, key string, data []byte, so ...StateOption) error
- func (c *GRPCClient) SayHello(ctx context.Context, in *SayHelloRequest) (*SayHelloResp, error)
- func (c *GRPCClient) SubscribeConfiguration(ctx context.Context, in *ConfigurationRequestItem) WatchChan
- func (c *GRPCClient) TryLock(ctx context.Context, req *runtimev1pb.TryLockRequest) (*runtimev1pb.TryLockResponse, error)
- func (c *GRPCClient) Unlock(ctx context.Context, req *runtimev1pb.UnlockRequest) (*runtimev1pb.UnlockResponse, error)
- type OperationType
- type SaveConfigurationRequest
- type SayHelloRequest
- type SayHelloResp
- type SetStateItem
- type StateConcurrency
- type StateConsistency
- type StateItem
- type StateOperation
- type StateOption
- type StateOptions
- type SubConfigurationResp
- type WatchChan
- type WatchResponse
Constants ¶
const ( // StateConsistencyUndefined is the undefined value for state consistency. StateConsistencyUndefined StateConsistency = 0 // StateConsistencyEventual represents eventual state consistency value. StateConsistencyEventual StateConsistency = 1 // StateConsistencyStrong represents strong state consistency value. StateConsistencyStrong StateConsistency = 2 // StateConcurrencyUndefined is the undefined value for state concurrency. StateConcurrencyUndefined StateConcurrency = 0 // StateConcurrencyFirstWrite represents first write concurrency value. StateConcurrencyFirstWrite StateConcurrency = 1 // StateConcurrencyLastWrite represents last write concurrency value. StateConcurrencyLastWrite StateConcurrency = 2 // StateOperationTypeUndefined is the undefined value for state operation type. StateOperationTypeUndefined OperationType = 0 // StateOperationTypeUpsert represents upsert operation type value. StateOperationTypeUpsert OperationType = 1 // StateOperationTypeDelete represents delete operation type value. StateOperationTypeDelete OperationType = 2 // UndefinedType represents undefined type value UndefinedType = "undefined" )
Variables ¶
This section is empty.
Functions ¶
func GoWithRecover ¶
func GoWithRecover(handler func(), recoverHandler func(r interface{}))
GoWithRecover wraps a `go func()` with recover()
func RegisterRecoverLogger ¶
RegisterRecoverLogger replace the log handler when go with recover catch a panic notice the replaced handler should be simple. if the handler panic, the recover handler will be failed.
Types ¶
type BulkStateItem ¶
type BulkStateItem struct { Key string Value []byte Etag string Metadata map[string]string Error string }
BulkStateItem represents a single state item.
type Client ¶
type Client interface { s3.ObjectStorageServiceClient // "mosn.io/layotto/spec/proto/extension/v1/cryption" cryption.CryptionServiceClient // "mosn.io/layotto/spec/proto/extension/v1/delay_queue" delay_queue.DelayQueueClient // "mosn.io/layotto/spec/proto/extension/v1/email" email.EmailServiceClient // "mosn.io/layotto/spec/proto/extension/v1/phone" phone.PhoneCallServiceClient // "mosn.io/layotto/spec/proto/extension/v1/sms" sms.SmsServiceClient // contains filtered or unexported methods }
Client is the interface for runtime client implementation.
func NewClient ¶
NewClient instantiates runtime client using runtime_GRPC_PORT environment variable as port. Note, this default factory function creates runtime client only once. All subsequent invocations will return the already created instance. To create multiple instances of the runtime client, use one of the parameterized factory functions:
NewClientWithPort(port string) (client Client, err error) NewClientWithAddress(address string) (client Client, err error) NewClientWithConnection(conn *grpc.ClientConn) Client
func NewClientWithAddress ¶
NewClientWithAddress instantiates runtime using specific address (including port).
func NewClientWithConnection ¶
func NewClientWithConnection(conn *grpc.ClientConn) Client
NewClientWithConnection instantiates runtime client using specific connection.
func NewClientWithPort ¶
NewClientWithPort instantiates runtime using specific port.
type ConfigurationItem ¶
type ConfigurationItem struct { // Required. The key of configuration item Key string // The content of configuration item // Empty if the configuration is not set, including the case that the configuration is changed from value-set to value-not-set. Content string // The group of configuration item. Group string // The label of configuration item. Label string // The tag list of configuration item. Tags map[string]string // The metadata which will be passed to configuration store component. Metadata map[string]string }
type ConfigurationRequestItem ¶
type ConfigurationRequestItem struct { // The name of configuration store. StoreName string // The application id which // Only used for admin, Ignored and reset for normal client AppId string // The group of keys. Group string // The label for keys. Label string // The keys to get. Keys []string // The metadata which will be sent to configuration store components. Metadata map[string]string }
ConfigurationRequestItem used for GET,DEL,SUB request
type DataContent ¶
type DataContent struct { // Data is the input data Data []byte // ContentType is the type of the data content ContentType string }
DataContent the service invocation content
type DeleteStateItem ¶
type DeleteStateItem SetStateItem
DeleteStateItem represents a single state to be deleted.
type GRPCClient ¶
type GRPCClient struct { s3.ObjectStorageServiceClient // "mosn.io/layotto/spec/proto/extension/v1/cryption" cryption.CryptionServiceClient // "mosn.io/layotto/spec/proto/extension/v1/delay_queue" delay_queue.DelayQueueClient // "mosn.io/layotto/spec/proto/extension/v1/email" email.EmailServiceClient // "mosn.io/layotto/spec/proto/extension/v1/phone" phone.PhoneCallServiceClient // "mosn.io/layotto/spec/proto/extension/v1/sms" sms.SmsServiceClient // contains filtered or unexported fields }
GRPCClient is the gRPC implementation of runtime client.
func (*GRPCClient) Close ¶
func (c *GRPCClient) Close()
Close cleans up all resources created by the client.
func (*GRPCClient) DeleteBulkState ¶
DeleteBulkState deletes content for multiple keys from store.
func (*GRPCClient) DeleteBulkStateItems ¶
func (c *GRPCClient) DeleteBulkStateItems(ctx context.Context, storeName string, items []*DeleteStateItem) error
DeleteBulkState deletes content for multiple keys from store.
func (*GRPCClient) DeleteConfiguration ¶
func (c *GRPCClient) DeleteConfiguration(ctx context.Context, in *ConfigurationRequestItem) error
DeleteConfiguration deletes configuration from configuration store.
func (*GRPCClient) DeleteState ¶
func (c *GRPCClient) DeleteState(ctx context.Context, storeName, key string) error
DeleteState deletes content from store using default state options.
func (*GRPCClient) DeleteStateWithETag ¶
func (c *GRPCClient) DeleteStateWithETag(ctx context.Context, storeName, key string, etag *ETag, meta map[string]string, opts *StateOptions) error
DeleteStateWithETag deletes content from store using provided state options and etag.
func (*GRPCClient) ExecuteStateTransaction ¶
func (c *GRPCClient) ExecuteStateTransaction(ctx context.Context, storeName string, meta map[string]string, ops []*StateOperation) error
ExecuteStateTransaction provides way to execute multiple operations on a specified store.
func (*GRPCClient) GetBulkSecret ¶
func (c *GRPCClient) GetBulkSecret(ctx context.Context, in *runtimev1pb.GetBulkSecretRequest, opts ...grpc.CallOption) (*runtimev1pb.GetBulkSecretResponse, error)
func (*GRPCClient) GetBulkState ¶
func (c *GRPCClient) GetBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string, parallelism int32) ([]*BulkStateItem, error)
GetBulkState retrieves state for multiple keys from specific store.
func (*GRPCClient) GetConfiguration ¶
func (c *GRPCClient) GetConfiguration(ctx context.Context, in *ConfigurationRequestItem) ([]*ConfigurationItem, error)
func (*GRPCClient) GetNextId ¶
func (c *GRPCClient) GetNextId(ctx context.Context, req *runtimev1pb.GetNextIdRequest) (*runtimev1pb.GetNextIdResponse, error)
func (*GRPCClient) GetSecret ¶
func (c *GRPCClient) GetSecret(ctx context.Context, in *runtimev1pb.GetSecretRequest, opts ...grpc.CallOption) (*runtimev1pb.GetSecretResponse, error)
func (*GRPCClient) GetState ¶
func (c *GRPCClient) GetState(ctx context.Context, storeName, key string) (item *StateItem, err error)
GetState retrieves state from specific store using default consistency option.
func (*GRPCClient) GetStateWithConsistency ¶
func (c *GRPCClient) GetStateWithConsistency(ctx context.Context, storeName, key string, meta map[string]string, sc StateConsistency) (item *StateItem, err error)
GetStateWithConsistency retrieves state from specific store using provided state consistency.
func (*GRPCClient) InvokeMethod ¶
func (c *GRPCClient) InvokeMethod(ctx context.Context, appID, methodName, verb string) (out []byte, err error)
InvokeMethod invokes service without raw data ([]byte).
func (*GRPCClient) InvokeMethodWithContent ¶
func (c *GRPCClient) InvokeMethodWithContent(ctx context.Context, appID, methodName, verb string, content *DataContent) (out []byte, err error)
InvokeMethodWithContent invokes service without content (data + content type).
func (*GRPCClient) InvokeMethodWithCustomContent ¶
func (c *GRPCClient) InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, content interface{}) (out []byte, err error)
InvokeMethodWithCustomContent invokes service with custom content (struct + content type).
func (*GRPCClient) PublishEvent ¶
func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error
PublishEvent publishes data onto specific pubsub topic.
func (*GRPCClient) PublishEventfromCustomContent ¶
func (c *GRPCClient) PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error
PublishEventfromCustomContent serializes an struct and publishes its contents as data (JSON) onto topic in specific pubsub component.
func (*GRPCClient) SaveBulkState ¶
func (c *GRPCClient) SaveBulkState(ctx context.Context, storeName string, items ...*SetStateItem) error
SaveBulkState saves the multiple state item to store.
func (*GRPCClient) SaveConfiguration ¶
func (c *GRPCClient) SaveConfiguration(ctx context.Context, in *SaveConfigurationRequest) error
SaveConfiguration saves configuration into configuration store.
func (*GRPCClient) SaveState ¶
func (c *GRPCClient) SaveState(ctx context.Context, storeName, key string, data []byte, so ...StateOption) error
SaveState saves the raw data into store, default options: strong, last-write
func (*GRPCClient) SayHello ¶
func (c *GRPCClient) SayHello(ctx context.Context, in *SayHelloRequest) (*SayHelloResp, error)
func (*GRPCClient) SubscribeConfiguration ¶
func (c *GRPCClient) SubscribeConfiguration(ctx context.Context, in *ConfigurationRequestItem) WatchChan
SubscribeConfiguration gets configuration from configuration store and subscribe the updates.
func (*GRPCClient) TryLock ¶
func (c *GRPCClient) TryLock(ctx context.Context, req *runtimev1pb.TryLockRequest) (*runtimev1pb.TryLockResponse, error)
func (*GRPCClient) Unlock ¶
func (c *GRPCClient) Unlock(ctx context.Context, req *runtimev1pb.UnlockRequest) (*runtimev1pb.UnlockResponse, error)
type OperationType ¶
type OperationType int
OperationType is the operation enum type.
func (OperationType) String ¶
func (o OperationType) String() string
String returns the string value of the OperationType.
type SaveConfigurationRequest ¶
type SaveConfigurationRequest struct { // The name of configuration store. StoreName string // The application id which // Only used for admin, ignored and reset for normal client AppId string // The list of configuration items to save. // To delete a exist item, set the key (also label) and let content to be empty Items []*ConfigurationItem // The metadata which will be sent to configuration store components. Metadata map[string]string }
type SayHelloRequest ¶
type SayHelloRequest struct {
ServiceName string
}
type SayHelloResp ¶
type SayHelloResp struct {
Hello string
}
type SetStateItem ¶
type SetStateItem struct { Key string Value []byte Etag *ETag Metadata map[string]string Options *StateOptions }
SetStateItem represents a single state to be persisted.
type StateConcurrency ¶
type StateConcurrency int
StateConcurrency is the concurrency enum type.
func (StateConcurrency) GetPBConcurrency ¶
func (s StateConcurrency) GetPBConcurrency() runtimev1pb.StateOptions_StateConcurrency
GetPBConcurrency get concurrency pb value
func (StateConcurrency) String ¶
func (s StateConcurrency) String() string
String returns the string value of the StateConcurrency.
type StateConsistency ¶
type StateConsistency int
StateConsistency is the consistency enum type.
func (StateConsistency) GetPBConsistency ¶
func (s StateConsistency) GetPBConsistency() runtimev1pb.StateOptions_StateConsistency
GetPBConsistency get consistency pb value
func (StateConsistency) String ¶
func (s StateConsistency) String() string
String returns the string value of the StateConsistency.
type StateOperation ¶
type StateOperation struct { Type OperationType Item *SetStateItem }
StateOperation is a collection of StateItems with a store name.
type StateOption ¶
type StateOption func(*StateOptions)
StateOption StateOptions's function type
func WithConcurrency ¶
func WithConcurrency(concurrency StateConcurrency) StateOption
WithConcurrency set StateOptions's Concurrency
func WithConsistency ¶
func WithConsistency(consistency StateConsistency) StateOption
WithConsistency set StateOptions's consistency
type StateOptions ¶
type StateOptions struct { Concurrency StateConcurrency Consistency StateConsistency }
StateOptions represents the state store persistence policy.
type SubConfigurationResp ¶
type SubConfigurationResp struct { // The name of configuration store. StoreName string // The application id which // Only used for admin, ignored and reset for normal client AppId string // The list of configuration items to save. // To delete a exist item, set the key (also label) and let content to be empty Items []*ConfigurationItem }
type WatchChan ¶
type WatchChan <-chan WatchResponse
type WatchResponse ¶
type WatchResponse struct { Item *SubConfigurationResp Err error }