grpc

package
v7.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 32 Imported by: 2

Documentation

Overview

  • Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors *

  • 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 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors *

  • 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-2024 Open Networking Foundation (ONF) and the ONF Contributors

* 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 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors

* 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 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors

* 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-2024 Open Networking Foundation (ONF) and the ONF Contributors

* 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.

Index

Constants

View Source
const (
	DefaultBackoffInitialInterval = 100 * time.Millisecond
	DefaultBackoffMaxInterval     = 5 * time.Second
	DefaultBackoffMaxElapsedTime  = 0 * time.Second // No time limit
	DefaultGRPCMonitorInterval    = 5 * time.Second
)

Variables

This section is empty.

Functions

func SetFromEnvVariable

func SetFromEnvVariable(key string, variableToSet interface{}) error

Types

type Backoff

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

func NewBackoff

func NewBackoff(initialInterval, maxInterval, maxElapsedTime time.Duration) *Backoff

func (*Backoff) Backoff

func (bo *Backoff) Backoff(ctx context.Context) error

func (*Backoff) Reset

func (bo *Backoff) Reset()

type Client

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

func NewClient

func NewClient(clientEndpoint, serverEndpoint, remoteServiceName string, onRestart RestartedHandler,
	opts ...ClientOption) (*Client, error)

func (*Client) GetAdapterServiceClient

func (c *Client) GetAdapterServiceClient() (adapter_service.AdapterServiceClient, error)

GetAdapterServiceClient is a helper function that returns a concrete service instead of the GetClient() API which returns an interface

func (*Client) GetClient

func (c *Client) GetClient() (interface{}, error)

func (*Client) GetCoreServiceClient

func (c *Client) GetCoreServiceClient() (core_service.CoreServiceClient, error)

GetCoreServiceClient is a helper function that returns a concrete service instead of the GetClient() API which returns an interface

func (*Client) GetOltInterAdapterServiceClient

func (c *Client) GetOltInterAdapterServiceClient() (olt_inter_adapter_service.OltInterAdapterServiceClient, error)

GetOltAdapterServiceClient is a helper function that returns a concrete service instead of the GetClient() API which returns an interface

func (*Client) GetOnuInterAdapterServiceClient

func (c *Client) GetOnuInterAdapterServiceClient() (onu_inter_adapter_service.OnuInterAdapterServiceClient, error)

GetOnuAdapterServiceClient is a helper function that returns a concrete service instead of the GetClient() API which returns an interface

func (*Client) Reset

func (c *Client) Reset(ctx context.Context)

func (*Client) SetService

func (c *Client) SetService(srv interface{})

SetService is used for testing only

func (*Client) Start

func (c *Client) Start(ctx context.Context, handler GetServiceClient, retry_interceptor ...grpc.UnaryClientInterceptor)

Start kicks off the adapter agent by trying to connect to the adapter

func (*Client) Stop

func (c *Client) Stop(ctx context.Context)

func (*Client) SubscribeForLiveness

func (c *Client) SubscribeForLiveness(callback func(timestamp time.Time))

type ClientOption

type ClientOption func(*Client)

func ClientContextData

func ClientContextData(data string) ClientOption

type GetServiceClient

type GetServiceClient func(context.Context, *grpc.ClientConn) interface{}

type GrpcSecurity

type GrpcSecurity struct {
	KeyFile  string
	CertFile string
	CaFile   string
}

type GrpcServer

type GrpcServer struct {
	*GrpcSecurity
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(
	address string,
	certs *GrpcSecurity,
	secure bool,
	probe ReadyProbe,
) *GrpcServer

Instantiate a GRPC server data structure

func (*GrpcServer) AddService

func (s *GrpcServer) AddService(
	registerFunction func(*grpc.Server),
)

AddService appends a generic service request function

func (*GrpcServer) Start

func (s *GrpcServer) Start(ctx context.Context)

Start prepares the GRPC server and starts servicing requests

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

Stop servicing GRPC requests

type MockCoreServiceHandler

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

MockCoreServiceHandler implements the methods in the core service

func NewMockCoreServiceHandler

func NewMockCoreServiceHandler() *MockCoreServiceHandler

func (*MockCoreServiceHandler) ChildDeviceDetected

func (handler *MockCoreServiceHandler) ChildDeviceDetected(context.Context, *ca.DeviceDiscovery) (*voltha.Device, error)

func (*MockCoreServiceHandler) ChildDevicesDetected

func (handler *MockCoreServiceHandler) ChildDevicesDetected(context.Context, *common.ID) (*empty.Empty, error)

func (*MockCoreServiceHandler) ChildDevicesLost

func (handler *MockCoreServiceHandler) ChildDevicesLost(context.Context, *common.ID) (*empty.Empty, error)

func (*MockCoreServiceHandler) ChildrenStateUpdate

func (handler *MockCoreServiceHandler) ChildrenStateUpdate(context.Context, *ca.DeviceStateFilter) (*empty.Empty, error)

func (*MockCoreServiceHandler) DeleteAllPorts

func (handler *MockCoreServiceHandler) DeleteAllPorts(context.Context, *common.ID) (*empty.Empty, error)

func (*MockCoreServiceHandler) DevicePMConfigUpdate

func (handler *MockCoreServiceHandler) DevicePMConfigUpdate(context.Context, *voltha.PmConfigs) (*empty.Empty, error)

func (*MockCoreServiceHandler) DeviceReasonUpdate

func (handler *MockCoreServiceHandler) DeviceReasonUpdate(context.Context, *ca.DeviceReason) (*empty.Empty, error)

func (*MockCoreServiceHandler) DeviceStateUpdate

func (handler *MockCoreServiceHandler) DeviceStateUpdate(context.Context, *ca.DeviceStateFilter) (*empty.Empty, error)

func (*MockCoreServiceHandler) DeviceUpdate

func (handler *MockCoreServiceHandler) DeviceUpdate(context.Context, *voltha.Device) (*empty.Empty, error)

func (*MockCoreServiceHandler) GetChildDevice

func (*MockCoreServiceHandler) GetChildDeviceWithProxyAddress

func (handler *MockCoreServiceHandler) GetChildDeviceWithProxyAddress(context.Context, *voltha.Device_ProxyAddress) (*voltha.Device, error)

func (*MockCoreServiceHandler) GetChildDevices

func (handler *MockCoreServiceHandler) GetChildDevices(context.Context, *common.ID) (*voltha.Devices, error)

func (*MockCoreServiceHandler) GetDevice

func (handler *MockCoreServiceHandler) GetDevice(ctx context.Context, id *common.ID) (*voltha.Device, error)

func (*MockCoreServiceHandler) GetDevicePort

func (handler *MockCoreServiceHandler) GetDevicePort(context.Context, *ca.PortFilter) (*voltha.Port, error)

func (*MockCoreServiceHandler) GetHealthStatus

func (*MockCoreServiceHandler) GetPorts

func (*MockCoreServiceHandler) ListDevicePorts

func (handler *MockCoreServiceHandler) ListDevicePorts(context.Context, *common.ID) (*voltha.Ports, error)

func (*MockCoreServiceHandler) PortCreated

func (handler *MockCoreServiceHandler) PortCreated(context.Context, *voltha.Port) (*empty.Empty, error)

func (*MockCoreServiceHandler) PortStateUpdate

func (handler *MockCoreServiceHandler) PortStateUpdate(context.Context, *ca.PortState) (*empty.Empty, error)

func (*MockCoreServiceHandler) PortsStateUpdate

func (handler *MockCoreServiceHandler) PortsStateUpdate(context.Context, *ca.PortStateFilter) (*empty.Empty, error)

func (*MockCoreServiceHandler) ReconcileChildDevices

func (handler *MockCoreServiceHandler) ReconcileChildDevices(context.Context, *common.ID) (*empty.Empty, error)

Additional API found in the Core - unused?

func (*MockCoreServiceHandler) RegisterAdapter

func (handler *MockCoreServiceHandler) RegisterAdapter(ctx context.Context, reg *ca.AdapterRegistration) (*empty.Empty, error)

func (*MockCoreServiceHandler) SendPacketIn

func (handler *MockCoreServiceHandler) SendPacketIn(context.Context, *ca.PacketIn) (*empty.Empty, error)

func (*MockCoreServiceHandler) Start

func (handler *MockCoreServiceHandler) Start()

func (*MockCoreServiceHandler) Stop

func (handler *MockCoreServiceHandler) Stop()

func (*MockCoreServiceHandler) UpdateImageDownload

func (handler *MockCoreServiceHandler) UpdateImageDownload(context.Context, *voltha.ImageDownload) (*empty.Empty, error)

type ReadyProbe

type ReadyProbe interface {
	IsReady() bool
}

Interface allows probes to be attached to server A probe must support the IsReady() method

type RestartedHandler

type RestartedHandler func(ctx context.Context, endPoint string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL