Exemplo n.º 1
0
func GoRpcServerOpts(env jutil.Env, obj jutil.Object) ([]rpc.ServerOpt, error) {
	var opts []rpc.ServerOpt

	if opt, err := jutil.JBoolField(env, obj, "servesMountTable"); err != nil {
		return nil, err
	} else {
		opts = append(opts, options.ServesMountTable(opt))
	}

	if opt, err := getDuration(env, obj, "lameDuckTimeout"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.LameDuckTimeout(*opt))
	}

	if opt, err := jutil.JBoolField(env, obj, "isLeaf"); err != nil {
		return nil, err
	} else {
		opts = append(opts, options.IsLeaf(opt))
	}

	if opt, err := getDuration(env, obj, "channelTimeout"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.ChannelTimeout(*opt))
	}

	return opts, nil
}
Exemplo n.º 2
0
func GoRpcOpts(env jutil.Env, obj jutil.Object) ([]rpc.CallOpt, error) {
	var opts []rpc.CallOpt

	if opt, err := getAuthorizer(env, obj, "nameResolutionAuthorizer"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.NameResolutionAuthorizer{opt})
	}

	if opt, err := getAuthorizer(env, obj, "serverAuthorizer"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.ServerAuthorizer{opt})
	}

	if opt, err := getPreresolved(env, obj); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.Preresolved{opt})
	}

	if opt, err := jutil.JBoolField(env, obj, "noRetry"); err != nil {
		return nil, err
	} else if opt {
		opts = append(opts, options.NoRetry{})
	}

	if opt, err := getDuration(env, obj, "connectionTimeout"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.ConnectionTimeout(*opt))
	}

	if opt, err := getDuration(env, obj, "channelTimeout"); err != nil {
		return nil, err
	} else if opt != nil {
		opts = append(opts, options.ChannelTimeout(*opt))
	}

	return opts, nil
}