You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: channels.go
    path of file: ./repos/dapr/pkg/runtime/channels
    
    the code of the file until where you have to start completion: /*
Copyright 2023 The Dapr 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
limitation
    
func (c *Channels) Refresh() error {
	c.lock.Lock()
	defer c.lock.Unlock()

	log.Debug("Refreshing channels")

	httpEndpChannel, err := channelhttp.CreateHTTPChannel(c.appHTTPChannelConfig())
	if err != nil {
		return fmt.Errorf("failed to create external HTTP app channel: %w", err)
	}

	endpChannels, err := c.initEndpointChannels()
	if err != nil {
		return fmt.Errorf("failed to create HTTP endpoints channels: %w", err)
	}

	c.httpEndpChannel = httpEndpChannel
	c.endpChannels = endpChannels

	if c.appConnectionConfig.Port == 0 {
		log.Warn("App channel is not initialized. Did you configure an app-port?")
		return nil
	}

	var appChannel channel.AppChannel
	if c.appConnectionConfig.Protocol.IsHTTP() {
		// Create a HTTP channel
		appChannel, err = channelhttp.CreateHTTPChannel(c.appHTTPChannelConfig())
		if err != nil {
			return fmt.Errorf("failed to create HTTP app channel: %w", err)
		}
		appChannel.(*channelhttp.Channel).SetAppHealthCheckPath(c.appConnectionConfig.HealthCheckHTTPPath)
	} else {
		// create gRPC app channel
		appChannel, err = c.grpc.GetAppChannel()
		if err != nil {
			return fmt.Errorf("failed to create gRPC app channel: %w", err)
		}
	}

	c.appChannel = appChannel
	log.Debug("Channels refreshed")

	return nil
}