Documentation
¶
Index ¶
- Constants
- func ApplyClusterRole(ctx context.Context, clusterRoles typedrbacv1.ClusterRoleInterface, ...) error
- func ApplyConfigMap(ctx context.Context, configMaps typedcorev1.ConfigMapInterface, ...) error
- func ApplyDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, ...) error
- func ApplyDispatcherDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, ...) error
- func ApplyRoleBinding(ctx context.Context, roleBindings typedrbacv1.RoleBindingInterface, ...) error
- func ApplyServiceAccount(ctx context.Context, serviceAccounts typedcorev1.ServiceAccountInterface, ...) error
- func PayloadLimit(client NATSClient, requested *resource.Quantity) *resource.Quantity
- func RenderClusterRole() *rbacv1.ClusterRole
- func RenderConfigMap(namespace string, connection Connection, stream string, limits Limits) (*corev1.ConfigMap, error)
- func RenderDeployment(namespace string, connection Connection, stream string, limits Limits, ...) (*appsv1.Deployment, error)
- func RenderDispatcherDeployment(namespace string, connection Connection, stream string, limits Limits, ...) (*appsv1.Deployment, error)
- func RenderRoleBinding(namespace string) *rbacv1.RoleBinding
- func RenderServiceAccount(namespace string) *corev1.ServiceAccount
- func ValidateNATS(client NATSClient, stream string, dispatchTimeout time.Duration) error
- type AuthMethod
- type Connection
- type Limits
- type NATSClient
- type SecretGetter
Constants ¶
const ( // ConfigMapName is the name of the cluster-wide config ConfigMap. ConfigMapName = "cluster" // ConfigMapKey is the key that holds the cluster config in the ConfigMap. ConfigMapKey = "cluster.yaml" )
const ( // DeploymentName is the name of the cluster-wide dispatcher Deployment. DeploymentName = "dispatcher" // ContainerName is the name of the dispatcher container. ContainerName = "dispatcher" )
const ( // EnvNATSURL holds the NATS URL in the dispatcher environment. EnvNATSURL = "NATS_URL" // EnvNATSSecret holds the NATS Secret name in the dispatcher environment. EnvNATSSecret = "NATS_SECRET" // EnvNATSAuth holds the NATS authentication method in the dispatcher environment. EnvNATSAuth = "NATS_AUTH" // EnvNATSTLS holds the NATS TLS setting in the dispatcher environment. EnvNATSTLS = "NATS_TLS" // EnvNATSStream holds the NATS stream name in the dispatcher environment. EnvNATSStream = "NATS_STREAM" // EnvNATSMaxPayload holds the NATS payload limit in the dispatcher environment. EnvNATSMaxPayload = "NATS_MAX_PAYLOAD" // EnvDispatchAttempts holds the dispatch attempt limit in the dispatcher environment. EnvDispatchAttempts = "DISPATCH_ATTEMPTS" // EnvDispatchTimeout holds the dispatch timeout in the dispatcher environment. EnvDispatchTimeout = "DISPATCH_TIMEOUT" // EnvWorkflowTTL holds the workflow retention in the dispatcher environment. EnvWorkflowTTL = "WORKFLOW_TTL" )
const ( // ServiceAccountName is the name of the dispatcher ServiceAccount. ServiceAccountName = "dispatcher" // ClusterRoleName is the name of the dispatcher ClusterRole. ClusterRoleName = "dispatcher" // RoleBindingName is the name of the dispatcher RoleBinding. RoleBindingName = "dispatcher" )
Variables ¶
This section is empty.
Functions ¶
func ApplyClusterRole ¶
func ApplyClusterRole(ctx context.Context, clusterRoles typedrbacv1.ClusterRoleInterface, desired *rbacv1.ClusterRole) error
ApplyClusterRole creates or replaces a ClusterRole.
func ApplyConfigMap ¶
func ApplyConfigMap(ctx context.Context, configMaps typedcorev1.ConfigMapInterface, desired *corev1.ConfigMap) error
ApplyConfigMap creates or replaces a ConfigMap.
func ApplyDeployment ¶
func ApplyDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, desired *appsv1.Deployment) error
ApplyDeployment creates or replaces a Deployment.
func ApplyDispatcherDeployment ¶
func ApplyDispatcherDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, desired *appsv1.Deployment) error
ApplyDispatcherDeployment is an alias for ApplyDeployment.
func ApplyRoleBinding ¶
func ApplyRoleBinding(ctx context.Context, roleBindings typedrbacv1.RoleBindingInterface, desired *rbacv1.RoleBinding) error
ApplyRoleBinding creates or replaces a RoleBinding.
func ApplyServiceAccount ¶
func ApplyServiceAccount(ctx context.Context, serviceAccounts typedcorev1.ServiceAccountInterface, desired *corev1.ServiceAccount) error
ApplyServiceAccount creates or replaces a ServiceAccount.
func PayloadLimit ¶
func PayloadLimit(client NATSClient, requested *resource.Quantity) *resource.Quantity
PayloadLimit returns the lower of the requested payload and the server maximum.
func RenderClusterRole ¶
func RenderClusterRole() *rbacv1.ClusterRole
RenderClusterRole builds the dispatcher ClusterRole.
func RenderConfigMap ¶
func RenderConfigMap(namespace string, connection Connection, stream string, limits Limits) (*corev1.ConfigMap, error)
RenderConfigMap builds the cluster ConfigMap from the connection and limits.
func RenderDeployment ¶
func RenderDeployment(namespace string, connection Connection, stream string, limits Limits, image ...string) (*appsv1.Deployment, error)
RenderDeployment builds the dispatcher Deployment from the connection, limits, and image.
func RenderDispatcherDeployment ¶
func RenderDispatcherDeployment(namespace string, connection Connection, stream string, limits Limits, image ...string) (*appsv1.Deployment, error)
RenderDispatcherDeployment is an alias for RenderDeployment.
func RenderRoleBinding ¶
func RenderRoleBinding(namespace string) *rbacv1.RoleBinding
RenderRoleBinding builds the RoleBinding that grants the ClusterRole to the dispatcher ServiceAccount.
func RenderServiceAccount ¶
func RenderServiceAccount(namespace string) *corev1.ServiceAccount
RenderServiceAccount builds the dispatcher ServiceAccount.
func ValidateNATS ¶
func ValidateNATS(client NATSClient, stream string, dispatchTimeout time.Duration) error
ValidateNATS rejects a server, stream, or stream limits that Octoba cannot use.
Types ¶
type AuthMethod ¶
type AuthMethod string
AuthMethod is the NATS authentication method recorded in the cluster config.
const ( AuthBasic AuthMethod = "basic" AuthToken AuthMethod = "token" AuthCredential AuthMethod = "credential" AuthNKey AuthMethod = "nkey" )
type Connection ¶
type Connection struct {
URL string
Secret string
Auth AuthMethod
TLS bool
}
Connection holds the NATS settings derived from the referenced Secret.
func ConnectionFromSecret ¶
func ConnectionFromSecret(secret *corev1.Secret, url string) (Connection, error)
ConnectionFromSecret derives the NATS connection from a Secret.
func Load ¶
func Load(ctx context.Context, secrets SecretGetter, url, name string) (Connection, *corev1.Secret, error)
Load reads the named Secret and derives the NATS connection from it.
func LoadConnection ¶
func LoadConnection(ctx context.Context, secrets SecretGetter, url, name string) (Connection, error)
LoadConnection reads the named Secret and derives the NATS connection from it.
type Limits ¶
type Limits struct {
NATSPayload *resource.Quantity
DispatchAttempts int
DispatchTimeout time.Duration
WorkflowTTL time.Duration
}
Limits are the cluster-wide dispatch limits recorded in the cluster config.
type NATSClient ¶
type NATSClient interface {
ServerVersion() string
StreamInfo(name string) (*nats.StreamInfo, error)
UpdateStream(config *nats.StreamConfig, options ...nats.JSOpt) (*nats.StreamInfo, error)
Close()
}
NATSClient is the subset of a NATS connection that Octoba needs.
func Connect ¶
func Connect(connection Connection, secret *corev1.Secret) (NATSClient, error)
Connect opens a NATS connection from a derived connection and its Secret.
type SecretGetter ¶
type SecretGetter interface {
Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1.Secret, error)
}
SecretGetter reads a Kubernetes Secret.