gateway

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

README

gateway

Package gateway is the main program for TCP and HTTP services.

demo

package main

import (
	"github.com/henrylee2cn/cfgo"
	"github.com/xiaoenai/ants/gateway"
)

func main() {
	cfg := gateway.NewConfig()
	cfgo.MustReg("gateway", cfg)
	// Run a gateway instance with default business logic and default socket protocol.
	gateway.Run(*cfg, nil, nil)
}

Documentation

Overview

Package gateway is the main program for TCP and HTTP services.

Copyright 2018 github.com/xiaoenai. All Rights Reserved.

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

This section is empty.

Variables

This section is empty.

Functions

func RegBodyCodecForShort

func RegBodyCodecForShort(contentType string, codecId byte)

RegBodyCodecForShort registers a mapping of content type to body coder (for http).

func Run

func Run(cfg Config, biz *types.Business, protoFunc socket.ProtoFunc) error

Run the gateway main program. If protoFunc=nil, socket.NewFastProtoFunc is used by default. If biz=nil, types.DefaultBusiness() is used by default.

func SetAccessTokenGetterForShort

func SetAccessTokenGetterForShort(fn func(args types.RequestArgs) string)

SetAccessTokenGetterForShort sets the function to get access token (for http).

Types

type Config

type Config struct {
	EnableOuterHttp bool                     `yaml:"enable_outer_http"`
	EnableOuterTcp  bool                     `yaml:"enable_outer_tcp"`
	OuterHttpServer short.OuterHttpSrvConfig `yaml:"outer_http_server"`
	OuterTcpServer  ant.SrvConfig            `yaml:"outer_tpc_server"`
	InnerTcpServer  ant.SrvConfig            `yaml:"inner_tcp_server"`
	InnerTcpClient  ant.CliConfig            `yaml:"inner_tcp_client"`
	Etcd            etcd.EasyConfig          `yaml:"etcd"`
	Redis           redis.Config             `yaml:"redis"`
}

Config app config

func NewConfig

func NewConfig() *Config

NewConfig creates a default config.

func (*Config) Reload

func (c *Config) Reload(bind cfgo.BindFunc) error

Reload Bi-directionally synchronizes config between YAML file and memory.

Directories

Path Synopsis
samples
simple command
Package types is a generated protocol buffer package.
Package types is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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